]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - application/api/exceptions/ApiAuthorizationException.php
Apply PHP Code Beautifier on source code for linter automatic fixes
[github/shaarli/Shaarli.git] / application / api / exceptions / ApiAuthorizationException.php
CommitLineData
18e67967
A
1<?php
2
3namespace Shaarli\Api\Exceptions;
4
5/**
6 * Class ApiAuthorizationException
7 *
8 * Request not authorized, return a 401 HTTP code.
9 */
10class ApiAuthorizationException extends ApiException
11{
12 /**
13 * {@inheritdoc}
14 */
15 public function getApiResponse()
16 {
17 $this->setMessage('Not authorized');
18 return $this->buildApiResponse(401);
19 }
20
21 /**
22 * Set the exception message.
23 *
24 * We only return a generic error message in production mode to avoid giving
25 * to much security information.
26 *
27 * @param $message string the exception message.
28 */
29 public function setMessage($message)
30 {
53054b2b 31 $original = $this->debug === true ? ': ' . $this->getMessage() : '';
18e67967
A
32 $this->message = $message . $original;
33 }
34}