2016-08-31 16:02:14 +05:30
|
|
|
<?php
|
|
|
|
namespace api\components;
|
|
|
|
|
|
|
|
use api\modules\authserver\exceptions\AuthserverException;
|
2016-09-03 04:24:22 +05:30
|
|
|
use api\modules\session\exceptions\SessionServerException;
|
2016-09-09 03:09:00 +05:30
|
|
|
use Yii;
|
2016-08-31 16:02:14 +05:30
|
|
|
|
|
|
|
class ErrorHandler extends \yii\web\ErrorHandler {
|
|
|
|
|
|
|
|
public function convertExceptionToArray($exception) {
|
2016-09-03 04:24:22 +05:30
|
|
|
if ($exception instanceof AuthserverException || $exception instanceof SessionServerException) {
|
2016-08-31 16:02:14 +05:30
|
|
|
return [
|
2016-08-31 16:05:43 +05:30
|
|
|
'error' => $exception->getName(),
|
2016-08-31 16:02:14 +05:30
|
|
|
'errorMessage' => $exception->getMessage(),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::convertExceptionToArray($exception);
|
|
|
|
}
|
|
|
|
|
2016-09-09 03:09:00 +05:30
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-31 16:02:14 +05:30
|
|
|
}
|