mirror of
https://github.com/elyby/accounts.git
synced 2024-12-23 22:00:06 +05:30
32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
namespace api\components;
|
|
|
|
use api\modules\authserver\exceptions\AuthserverException;
|
|
use api\modules\session\exceptions\SessionServerException;
|
|
use Yii;
|
|
|
|
class ErrorHandler extends \yii\web\ErrorHandler {
|
|
|
|
public function convertExceptionToArray($exception) {
|
|
if ($exception instanceof AuthserverException || $exception instanceof SessionServerException) {
|
|
return [
|
|
'error' => $exception->getName(),
|
|
'errorMessage' => $exception->getMessage(),
|
|
];
|
|
}
|
|
|
|
return parent::convertExceptionToArray($exception);
|
|
}
|
|
|
|
public function logException($exception) {
|
|
if ($exception instanceof AuthserverException) {
|
|
Yii::error($exception, AuthserverException::class . ':' . $exception->getName());
|
|
} elseif ($exception instanceof SessionServerException) {
|
|
Yii::error($exception, SessionServerException::class . ':' . $exception->getName());
|
|
} else {
|
|
parent::logException($exception);
|
|
}
|
|
}
|
|
|
|
}
|