Skip to content

Commit

Permalink
feat: 401 on UnauthorizedHttpException
Browse files Browse the repository at this point in the history
  • Loading branch information
petrleocompel committed Dec 8, 2022
1 parent cbd9f85 commit 11b202c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,16 @@ public function actionHandleError()

$category = Logger::LEVEL_ERROR;

if ($exception instanceof ErrorException) {

if ($exception instanceof \yii\web\UnauthorizedHttpException) {
http_response_code(401);
$this->_errors[] = [
'code' => get_class($exception),
'message' => $exception->getMessage(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
];
} else if ($exception instanceof ErrorException) {
switch ($exception->getCode()) {
case E_WARNING:
$type = 'PHP warning';
Expand Down

0 comments on commit 11b202c

Please sign in to comment.