2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2014-04-29 05:33:03 +00:00
|
|
|
|
2009-07-19 07:38:13 +00:00
|
|
|
/**
|
2014-04-29 05:33:03 +00:00
|
|
|
* A base exception to be caught by the upper levels.
|
2009-07-19 07:38:13 +00:00
|
|
|
*/
|
2020-01-26 13:19:35 +00:00
|
|
|
class SCoreException extends RuntimeException
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
public ?string $query;
|
|
|
|
public string $error;
|
2021-11-16 14:52:26 +00:00
|
|
|
public int $http_code = 500;
|
2020-01-26 13:19:35 +00:00
|
|
|
|
2019-11-11 16:43:04 +00:00
|
|
|
public function __construct(string $msg, ?string $query=null)
|
|
|
|
{
|
|
|
|
parent::__construct($msg);
|
2020-01-26 13:19:35 +00:00
|
|
|
$this->error = $msg;
|
2019-11-11 16:43:04 +00:00
|
|
|
$this->query = $query;
|
|
|
|
}
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2009-01-04 13:53:14 +00:00
|
|
|
|
2020-01-27 17:47:28 +00:00
|
|
|
class InstallerException extends RuntimeException
|
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
public string $title;
|
|
|
|
public string $body;
|
|
|
|
public int $exit_code;
|
2020-01-27 17:47:28 +00:00
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function __construct(string $title, string $body, int $exit_code)
|
2020-01-27 17:47:28 +00:00
|
|
|
{
|
2020-01-27 19:37:28 +00:00
|
|
|
parent::__construct($body);
|
2020-01-27 17:47:28 +00:00
|
|
|
$this->title = $title;
|
|
|
|
$this->body = $body;
|
2021-03-14 23:43:50 +00:00
|
|
|
$this->exit_code = $exit_code;
|
2020-01-27 17:47:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-16 14:52:26 +00:00
|
|
|
class UserErrorException extends SCoreException
|
|
|
|
{
|
|
|
|
public int $http_code = 400;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ServerErrorException extends SCoreException
|
|
|
|
{
|
|
|
|
public int $http_code = 500;
|
|
|
|
}
|
|
|
|
|
2009-07-19 07:38:13 +00:00
|
|
|
/**
|
2014-04-29 05:33:03 +00:00
|
|
|
* A fairly common, generic exception.
|
2009-07-19 07:38:13 +00:00
|
|
|
*/
|
2021-11-16 14:52:26 +00:00
|
|
|
class PermissionDeniedException extends UserErrorException
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2021-11-16 14:52:26 +00:00
|
|
|
public int $http_code = 403;
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2014-04-24 23:01:47 +00:00
|
|
|
|
2014-04-25 20:07:30 +00:00
|
|
|
/**
|
|
|
|
* This exception is used when an Image cannot be found by ID.
|
|
|
|
*/
|
2021-11-16 14:52:26 +00:00
|
|
|
class ImageDoesNotExist extends UserErrorException
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2021-11-16 14:52:26 +00:00
|
|
|
public int $http_code = 404;
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2015-07-12 21:40:28 +00:00
|
|
|
|
2021-11-10 19:33:51 +00:00
|
|
|
/**
|
|
|
|
* This exception is used when a User cannot be found by some criteria.
|
|
|
|
*/
|
2021-11-16 14:52:26 +00:00
|
|
|
class UserDoesNotExist extends UserErrorException
|
2021-11-10 19:33:51 +00:00
|
|
|
{
|
2021-11-16 14:52:26 +00:00
|
|
|
public int $http_code = 404;
|
2021-11-10 19:33:51 +00:00
|
|
|
}
|
|
|
|
|
2015-07-12 21:40:28 +00:00
|
|
|
/*
|
|
|
|
* For validate_input()
|
|
|
|
*/
|
2021-11-16 14:52:26 +00:00
|
|
|
class InvalidInput extends UserErrorException
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2021-11-16 14:52:26 +00:00
|
|
|
public int $http_code = 402;
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2019-06-09 18:22:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This is used by the image resizing code when there is not enough memory to perform a resize.
|
|
|
|
*/
|
2021-11-16 14:52:26 +00:00
|
|
|
class InsufficientMemoryException extends ServerErrorException
|
2019-06-09 18:22:48 +00:00
|
|
|
{
|
2019-06-11 14:06:47 +00:00
|
|
|
}
|
2020-01-26 13:19:35 +00:00
|
|
|
|
2019-06-11 14:06:47 +00:00
|
|
|
/*
|
|
|
|
* This is used by the image resizing code when there is an error while resizing
|
|
|
|
*/
|
2021-11-16 14:52:26 +00:00
|
|
|
class ImageResizeException extends ServerErrorException
|
2019-06-11 14:06:47 +00:00
|
|
|
{
|
2019-06-14 12:47:50 +00:00
|
|
|
}
|