Initial Commit of Files
PufferPanel v0.9 (Laravel) is now Pterodactyl 1.0
This commit is contained in:
commit
1489f7a694
154 changed files with 10159 additions and 0 deletions
8
app/Exceptions/AccountNotFoundException.php
Normal file
8
app/Exceptions/AccountNotFoundException.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
class AccountNotFoundException extends \Exception
|
||||
{
|
||||
|
||||
}
|
8
app/Exceptions/DisplayException.php
Normal file
8
app/Exceptions/DisplayException.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
class DisplayException extends \Exception
|
||||
{
|
||||
|
||||
}
|
78
app/Exceptions/Handler.php
Normal file
78
app/Exceptions/Handler.php
Normal file
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use DisplayException;
|
||||
use Debugbar;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dontReport = [
|
||||
HttpException::class,
|
||||
ModelNotFoundException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param \Exception $e
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $e)
|
||||
{
|
||||
return parent::report($e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $e
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($e instanceof ModelNotFoundException) {
|
||||
$e = new NotFoundHttpException($e->getMessage(), $e);
|
||||
}
|
||||
|
||||
if ($request->isXmlHttpRequest() || $request->ajax() || $request->is('/api/*')) {
|
||||
|
||||
$exception = 'An exception occured while attempting to perform this action, please try again.';
|
||||
|
||||
if ($e instanceof DisplayException) {
|
||||
$exception = $e->getMessage();
|
||||
}
|
||||
|
||||
// Live environment, just return a nice error.
|
||||
if(!env('APP_DEBUG', false)) {
|
||||
return response()->json([
|
||||
'error' => $exception
|
||||
], 500);
|
||||
}
|
||||
|
||||
// If we are debugging, return the exception in it's full manner.
|
||||
return response()->json([
|
||||
'error' => $e->getMessage(),
|
||||
'code' => $e->getCode(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine()
|
||||
], 500);
|
||||
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue