aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/api/exceptions/ApiAuthorizationException.php
diff options
context:
space:
mode:
authorArthur <arthur@hoa.ro>2016-12-20 11:30:05 +0100
committerGitHub <noreply@github.com>2016-12-20 11:30:05 +0100
commit80677a23e2e10d78bc527e9754286787b453ce61 (patch)
tree18feefc47f389171f3886b191fb14f2ace6d0175 /application/api/exceptions/ApiAuthorizationException.php
parente350aa750f9e9e742bb60a1e04ebd9e21f763c78 (diff)
parent18e6796726d73d7dc90ecdd16c181493941f5487 (diff)
downloadShaarli-80677a23e2e10d78bc527e9754286787b453ce61.tar.gz
Shaarli-80677a23e2e10d78bc527e9754286787b453ce61.tar.zst
Shaarli-80677a23e2e10d78bc527e9754286787b453ce61.zip
Merge pull request #666 from ArthurHoaro/slim-api
REST API structure using Slim framework
Diffstat (limited to 'application/api/exceptions/ApiAuthorizationException.php')
-rw-r--r--application/api/exceptions/ApiAuthorizationException.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/application/api/exceptions/ApiAuthorizationException.php b/application/api/exceptions/ApiAuthorizationException.php
new file mode 100644
index 00000000..0e3f4776
--- /dev/null
+++ b/application/api/exceptions/ApiAuthorizationException.php
@@ -0,0 +1,34 @@
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 {
31 $original = $this->debug === true ? ': '. $this->getMessage() : '';
32 $this->message = $message . $original;
33 }
34}