refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
30
app/Exceptions/FileNotFoundException.php
Normal file
30
app/Exceptions/FileNotFoundException.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Contracts\Filesystem\FileNotFoundException as FileNotFoundExceptionBase;
|
||||
|
||||
class FileNotFoundException extends FileNotFoundExceptionBase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $fileName;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param string $fileName
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($fileName)
|
||||
{
|
||||
$this->fileName = $fileName;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return 'File not found: '.$this->fileName;
|
||||
}
|
||||
}
|
||||
64
app/Exceptions/Handler.php
Normal file
64
app/Exceptions/Handler.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Throwable;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
{
|
||||
/**
|
||||
* A list of the exception types that should not be reported.
|
||||
*
|
||||
* @var array<int, class-string<Throwable>>
|
||||
*/
|
||||
protected $dontReport = [
|
||||
OAuthServerException::class,
|
||||
WrongIdException::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* Register the exception handling callbacks for the application.
|
||||
*
|
||||
* @return void
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
if (config('monica.sentry_support') && config('app.env') == 'production') {
|
||||
$this->reportable(function (Throwable $e) {
|
||||
if ($this->shouldReport($e) && app()->bound('sentry')) {
|
||||
app('sentry')->captureException($e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Throwable $e
|
||||
* @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function render($request, Throwable $e)
|
||||
{
|
||||
// hopefully catches those pesky token expiries
|
||||
// and send them back to login.
|
||||
if ($e instanceof TokenMismatchException) {
|
||||
return redirect()->route('loginRedirect');
|
||||
}
|
||||
|
||||
// Convert all non-http exceptions to a proper 500 http exception
|
||||
// if we don't do this exceptions are shown as a default template
|
||||
// instead of our own view in resources/views/errors/500.blade.php
|
||||
if ($this->shouldReport($e) && ! $this->isHttpException($e) && ! config('app.debug')) {
|
||||
$e = new HttpException(500, $e->getMessage());
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
}
|
||||
}
|
||||
12
app/Exceptions/MissingEnvVariableException.php
Normal file
12
app/Exceptions/MissingEnvVariableException.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if the env variable is not set or does not exist.
|
||||
*/
|
||||
class MissingEnvVariableException extends RuntimeException
|
||||
{
|
||||
}
|
||||
12
app/Exceptions/NoAccountException.php
Normal file
12
app/Exceptions/NoAccountException.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if the env variable is not set or does not exist.
|
||||
*/
|
||||
class NoAccountException extends RuntimeException
|
||||
{
|
||||
}
|
||||
9
app/Exceptions/NoCoordinatesException.php
Normal file
9
app/Exceptions/NoCoordinatesException.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class NoCoordinatesException extends RuntimeException
|
||||
{
|
||||
}
|
||||
13
app/Exceptions/RateLimitedSecondException.php
Normal file
13
app/Exceptions/RateLimitedSecondException.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class RateLimitedSecondException extends RuntimeException
|
||||
{
|
||||
public function __construct($e)
|
||||
{
|
||||
parent::__construct('', 429, $e);
|
||||
}
|
||||
}
|
||||
12
app/Exceptions/StripeException.php
Normal file
12
app/Exceptions/StripeException.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown by Stripe.
|
||||
*/
|
||||
class StripeException extends RuntimeException
|
||||
{
|
||||
}
|
||||
12
app/Exceptions/WrongIdException.php
Normal file
12
app/Exceptions/WrongIdException.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown by IdHasher if a desired key item is wrong.
|
||||
*/
|
||||
class WrongIdException extends RuntimeException
|
||||
{
|
||||
}
|
||||
12
app/Exceptions/WrongValueException.php
Normal file
12
app/Exceptions/WrongValueException.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
* Exception thrown if the given value is not in the list of authorized values.
|
||||
*/
|
||||
class WrongValueException extends RuntimeException
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user