mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-10-12 10:09:58 +00:00
Updated exception handler to reduce the amount of detail shown to prevent potentially sensitive details (like internal paths) being shown in the error message. Added an interface for specifically marking exceptions whos messages we may want to show. Thanks to Tanner Marks for reporting.
32 lines
667 B
PHP
32 lines
667 B
PHP
<?php
|
|
|
|
namespace BookStack\Exceptions;
|
|
|
|
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
|
|
|
class ApiAuthException extends \Exception implements HttpExceptionInterface, ShowsApiExceptionMessage
|
|
{
|
|
protected int $status;
|
|
|
|
public function __construct(string $message, int $statusCode = 401)
|
|
{
|
|
$this->status = $statusCode;
|
|
parent::__construct($message, $statusCode);
|
|
}
|
|
|
|
public function getStatusCode(): int
|
|
{
|
|
return $this->status;
|
|
}
|
|
|
|
public function getHeaders(): array
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public function getMessageForApi(): string
|
|
{
|
|
return $this->getMessage();
|
|
}
|
|
}
|