This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/core/exceptions.php

75 lines
1.2 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
2014-04-29 05:33:03 +00:00
namespace Shimmie2;
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
*/
class SCoreException extends \RuntimeException
{
public string $error;
public int $http_code = 500;
2020-01-26 13:19:35 +00:00
2024-01-04 22:48:56 +00:00
public function __construct(string $msg)
{
parent::__construct($msg);
2020-01-26 13:19:35 +00:00
$this->error = $msg;
}
}
class InstallerException extends \RuntimeException
2020-01-27 17:47:28 +00:00
{
public string $title;
public string $body;
public int $exit_code;
2020-01-27 17:47:28 +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;
$this->exit_code = $exit_code;
2020-01-27 17:47:28 +00:00
}
}
2024-02-11 15:47:40 +00:00
class UserError extends SCoreException
{
public int $http_code = 400;
}
2024-02-11 15:47:40 +00:00
class ServerError 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
*/
2024-02-11 15:47:40 +00:00
class PermissionDenied extends UserError
{
public int $http_code = 403;
}
2024-02-11 15:47:40 +00:00
class ObjectNotFound extends UserError
2021-11-10 19:33:51 +00:00
{
public int $http_code = 404;
2021-11-10 19:33:51 +00:00
}
2024-02-11 15:47:40 +00:00
class ImageNotFound extends ObjectNotFound
{
}
2024-02-11 15:47:40 +00:00
class UserNotFound extends ObjectNotFound
{
}
2020-01-26 13:19:35 +00:00
/*
2024-02-11 15:47:40 +00:00
* For validate_input()
*/
2024-02-11 15:47:40 +00:00
class InvalidInput extends UserError
{
2024-02-11 15:47:40 +00:00
public int $http_code = 402;
2019-06-14 12:47:50 +00:00
}