Upgraded exceptions stuff

This commit is contained in:
Graham Campbell
2016-01-21 13:06:39 +00:00
parent 61673153d5
commit f19eff244f
4 changed files with 18 additions and 21 deletions
@@ -14,16 +14,14 @@ namespace CachetHQ\Cachet\Foundation\Exceptions\Transformers;
use CachetHQ\Cachet\Bus\Exceptions\ExceptionInterface; use CachetHQ\Cachet\Bus\Exceptions\ExceptionInterface;
use Exception; use Exception;
use GrahamCampbell\Exceptions\Transformers\TransformerInterface; use GrahamCampbell\Exceptions\Transformers\TransformerInterface;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
* This is the exception transformer class. * This is the bus transformer class.
* *
* @author Graham Campbell <graham@alt-three.com> * @author Graham Campbell <graham@alt-three.com>
*/ */
class ExceptionTransformer implements TransformerInterface class BusTransformer implements TransformerInterface
{ {
/** /**
* Transform the provided exception. * Transform the provided exception.
@@ -36,8 +34,6 @@ class ExceptionTransformer implements TransformerInterface
{ {
if ($exception instanceof ExceptionInterface) { if ($exception instanceof ExceptionInterface) {
$exception = new BadRequestHttpException($exception->getMessage()); $exception = new BadRequestHttpException($exception->getMessage());
} elseif ($exception instanceof ModelNotFoundException) {
$exception = new NotFoundHttpException('Resource not found.');
} }
return $exception; return $exception;
+1 -1
View File
@@ -32,7 +32,7 @@
"graham-campbell/core": "^4.2", "graham-campbell/core": "^4.2",
"graham-campbell/markdown": "^6.0", "graham-campbell/markdown": "^6.0",
"graham-campbell/throttle": "^5.1", "graham-campbell/throttle": "^5.1",
"graham-campbell/exceptions": "^8.2", "graham-campbell/exceptions": "^8.3",
"guzzlehttp/guzzle": "^6.1", "guzzlehttp/guzzle": "^6.1",
"jenssegers/date": "^3.1", "jenssegers/date": "^3.1",
"mccool/laravel-auto-presenter": "^4.2", "mccool/laravel-auto-presenter": "^4.2",
Generated
+12 -12
View File
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "23040a215cf37e88ed03bb3dc2602aae", "hash": "a03ddb86888b5d17380401b81539fa2f",
"content-hash": "1c679656f822bf0dc48d83459cb5234c", "content-hash": "07e7bd2633a541cdb139d05193037ea6",
"packages": [ "packages": [
{ {
"name": "alt-three/bus", "name": "alt-three/bus",
@@ -1119,16 +1119,16 @@
}, },
{ {
"name": "graham-campbell/exceptions", "name": "graham-campbell/exceptions",
"version": "v8.2.0", "version": "v8.3.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/GrahamCampbell/Laravel-Exceptions.git", "url": "https://github.com/GrahamCampbell/Laravel-Exceptions.git",
"reference": "32ed22ec846c84475ed40d798bac5c7340f75bec" "reference": "9e5b00e6abff7a91730e52263c4a696aeeeef5d9"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/GrahamCampbell/Laravel-Exceptions/zipball/32ed22ec846c84475ed40d798bac5c7340f75bec", "url": "https://api.github.com/repos/GrahamCampbell/Laravel-Exceptions/zipball/9e5b00e6abff7a91730e52263c4a696aeeeef5d9",
"reference": "32ed22ec846c84475ed40d798bac5c7340f75bec", "reference": "9e5b00e6abff7a91730e52263c4a696aeeeef5d9",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1152,7 +1152,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "8.2-dev" "dev-master": "8.3-dev"
} }
}, },
"autoload": { "autoload": {
@@ -1184,7 +1184,7 @@
"laravel", "laravel",
"whoops" "whoops"
], ],
"time": "2016-01-15 12:51:42" "time": "2016-01-21 12:54:36"
}, },
{ {
"name": "graham-campbell/markdown", "name": "graham-campbell/markdown",
@@ -1745,12 +1745,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "30a1c93e08a05e9136cfdaf9b5da7a5039fb6106" "reference": "4966bbda682839d6cd02bbcbc07a6eb984f31ca0"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/30a1c93e08a05e9136cfdaf9b5da7a5039fb6106", "url": "https://api.github.com/repos/laravel/framework/zipball/4966bbda682839d6cd02bbcbc07a6eb984f31ca0",
"reference": "30a1c93e08a05e9136cfdaf9b5da7a5039fb6106", "reference": "4966bbda682839d6cd02bbcbc07a6eb984f31ca0",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1865,7 +1865,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2016-01-18 14:30:57" "time": "2016-01-20 20:38:15"
}, },
{ {
"name": "league/commonmark", "name": "league/commonmark",
+3 -2
View File
@@ -28,7 +28,8 @@ return [
'transformers' => [ 'transformers' => [
'GrahamCampbell\Exceptions\Transformers\AuthTransformer', 'GrahamCampbell\Exceptions\Transformers\AuthTransformer',
'GrahamCampbell\Exceptions\Transformers\CsrfTransformer', 'GrahamCampbell\Exceptions\Transformers\CsrfTransformer',
'CachetHQ\Cachet\Foundation\Exceptions\Transformers\ExceptionTransformer', 'GrahamCampbell\Exceptions\Transformers\ModelTransformer',
'CachetHQ\Cachet\Foundation\Exceptions\Transformers\BusTransformer',
], ],
/* /*
@@ -102,8 +103,8 @@ return [
'levels' => [ 'levels' => [
'Illuminate\Auth\Access\AuthorizationException' => 'warning', 'Illuminate\Auth\Access\AuthorizationException' => 'warning',
'Illuminate\Session\TokenMismatchException' => 'notice',
'Illuminate\Database\Eloquent\ModelNotFoundException' => 'warning', 'Illuminate\Database\Eloquent\ModelNotFoundException' => 'warning',
'Illuminate\Session\TokenMismatchException' => 'notice',
'Symfony\Component\HttpKernel\Exception\HttpExceptionInterface' => 'warning', 'Symfony\Component\HttpKernel\Exception\HttpExceptionInterface' => 'warning',
'Symfony\Component\Debug\Exception\FatalErrorException' => 'critical', 'Symfony\Component\Debug\Exception\FatalErrorException' => 'critical',
'Exception' => 'error', 'Exception' => 'error',