32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
namespace nulib;
|
|
|
|
use Exception;
|
|
|
|
/**
|
|
* Class AccessException: indiquer que la resource ou l'objet auquel on veut
|
|
* accéder n'est pas accessible. il s'agit donc d'une erreur de l'utilisateur
|
|
*/
|
|
class AccessException extends Exception {
|
|
static final function immutable_object(?string $dest=null, ?string $prefix=null): self {
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
if ($dest === null) $dest = "this object";
|
|
$message = "$dest is immutable";
|
|
return new static($prefix.$message);
|
|
}
|
|
|
|
static final function not_allowed(?string $action=null, ?string $prefix=null): self {
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
if ($action === null) $action = "this operation";
|
|
$message = "$action is not allowed";
|
|
return new static($prefix.$message);
|
|
}
|
|
|
|
static final function not_accessible(?string $dest=null, ?string $prefix=null): self {
|
|
if ($prefix) $prefix = "$prefix: ";
|
|
if ($dest === null) $dest = "this resource";
|
|
$message = "$dest is not accessible";
|
|
return new static($prefix.$message);
|
|
}
|
|
}
|