added default error messages to errorResponse and badRequest

This commit is contained in:
Jonathan Labreuille
2016-08-03 14:08:22 +02:00
parent 28c39d301c
commit 6675d5a20d
4 changed files with 13 additions and 9 deletions

View File

@ -15,11 +15,20 @@ abstract class Endpoint {
function errorResponse(
$errors = array(), $meta = array(), $status = Response::STATUS_NOT_FOUND
) {
if(empty($errors)) {
$errors = array(
'unknown' => __('An unknown error occurred.')
);
}
return new ErrorResponse($errors, $meta, $status);
}
function badRequest($errors = array(), $meta = array()) {
if(empty($errors)) {
$errors = array(
'bad_request' => __('Invalid request parameters.')
);
}
return new ErrorResponse($errors, $meta, Response::STATUS_BAD_REQUEST);
}
}