2016-12-15 10:13:00 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Shaarli\Api\Exceptions;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ApiAuthorizationException
|
|
|
|
*
|
|
|
|
* Request not authorized, return a 401 HTTP code.
|
|
|
|
*/
|
|
|
|
class ApiAuthorizationException extends ApiException
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function getApiResponse()
|
|
|
|
{
|
|
|
|
$this->setMessage('Not authorized');
|
|
|
|
return $this->buildApiResponse(401);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the exception message.
|
|
|
|
*
|
|
|
|
* We only return a generic error message in production mode to avoid giving
|
|
|
|
* to much security information.
|
|
|
|
*
|
|
|
|
* @param $message string the exception message.
|
|
|
|
*/
|
|
|
|
public function setMessage($message)
|
|
|
|
{
|
2023-05-24 11:35:15 +02:00
|
|
|
$original = $this->debug === true ? ': ' . $this->getMessage() : '';
|
2016-12-15 10:13:00 +01:00
|
|
|
$this->message = $message . $original;
|
|
|
|
}
|
|
|
|
}
|