Skip to content

Commit

Permalink
Catch all Exceptions (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
barryvdh authored and freekmurze committed Oct 5, 2016
1 parent 66a5405 commit 03ba15c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Controller.php
Expand Up @@ -2,6 +2,7 @@

namespace Spatie\SlashCommand;

use Exception;
use Illuminate\Config\Repository;
use Illuminate\Http\Request as IlluminateRequest;
use Illuminate\Http\Response as IlluminateResponse;
Expand Down Expand Up @@ -35,6 +36,16 @@ public function getResponse(): IlluminateResponse
try {
$response = $handler->handle($this->request);
} catch (SlackSlashCommandException $exception) {
$response = $exception->getResponse($this->request);
} catch (Exception $exception) {
$message = config('app.debug') ? (string) $exception : 'Whoops, something went wrong..';

$exception = new SlackSlashCommandException(
$message,
$exception->getCode(),
$exception
);

$response = $exception->getResponse($this->request);
}

Expand Down

0 comments on commit 03ba15c

Please sign in to comment.