mirror of
https://github.com/flarum/core.git
synced 2025-10-17 09:46:14 +02:00
Implement interface to serialize exceptions to JSON-API format
Related to #118
This commit is contained in:
@@ -12,6 +12,26 @@ namespace Flarum\Core\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class PermissionDeniedException extends Exception
|
||||
class PermissionDeniedException extends Exception implements JsonApiSerializable
|
||||
{
|
||||
/**
|
||||
* Return the HTTP status code to be used for this exception.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStatusCode()
|
||||
{
|
||||
return 401;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of errors, formatted as JSON-API error objects.
|
||||
*
|
||||
* @see http://jsonapi.org/format/#error-objects
|
||||
* @return array
|
||||
*/
|
||||
public function getErrors()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user