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