public static function forException(Exception $exception)
{
if (Config::getValue('debug')) {
return new Error($exception->getCode(), self::_classNameAndMessage($exception));
}
if ($exception instanceof UserException) {
return new Error($exception->getCode(), $exception->getMessage());
}
return new Error($exception->getCode(), I18n::t('exception.unknown'), $exception->getMessage());
}