mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-08 00:03:12 +08:00
Centralized prefix for problem detail types
This commit is contained in:
@@ -9,6 +9,7 @@ use Mezzio\ProblemDetails\Exception\CommonProblemDetailsExceptionTrait;
|
||||
use Mezzio\ProblemDetails\Exception\ProblemDetailsExceptionInterface;
|
||||
|
||||
use function implode;
|
||||
use function Shlinkio\Shlink\Core\toProblemDetailsType;
|
||||
use function sprintf;
|
||||
|
||||
class MissingAuthenticationException extends RuntimeException implements ProblemDetailsExceptionInterface
|
||||
@@ -16,7 +17,7 @@ class MissingAuthenticationException extends RuntimeException implements Problem
|
||||
use CommonProblemDetailsExceptionTrait;
|
||||
|
||||
private const TITLE = 'Invalid authorization';
|
||||
public const TYPE = 'https://shlink.io/api/error/missing-authentication';
|
||||
public const ERROR_CODE = 'missing-authentication';
|
||||
|
||||
public static function forHeaders(array $expectedHeaders): self
|
||||
{
|
||||
@@ -43,7 +44,7 @@ class MissingAuthenticationException extends RuntimeException implements Problem
|
||||
|
||||
$e->detail = $message;
|
||||
$e->title = self::TITLE;
|
||||
$e->type = self::TYPE;
|
||||
$e->type = toProblemDetailsType(self::ERROR_CODE);
|
||||
$e->status = StatusCodeInterface::STATUS_UNAUTHORIZED;
|
||||
|
||||
return $e;
|
||||
|
||||
Reference in New Issue
Block a user