mirror of
https://git.proxmox.com/git/pve-common
synced 2025-08-06 04:29:33 +00:00
new helper raise_perm_exc
This commit is contained in:
parent
815b2abaea
commit
8c77914e75
@ -21,7 +21,7 @@ use overload 'cmp' => sub {
|
|||||||
return "$a" cmp "$b"; # compare as string
|
return "$a" cmp "$b"; # compare as string
|
||||||
};
|
};
|
||||||
|
|
||||||
@EXPORT_OK = qw(raise raise_param_exc);
|
@EXPORT_OK = qw(raise raise_param_exc raise_perm_exc);
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, $msg, %param) = @_;
|
my ($class, $msg, %param) = @_;
|
||||||
@ -53,6 +53,25 @@ sub raise {
|
|||||||
die $exc;
|
die $exc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub raise_perm_exc {
|
||||||
|
my ($what) = @_;
|
||||||
|
|
||||||
|
my $param = { code => HTTP_FORBIDDEN };
|
||||||
|
|
||||||
|
my $msg = "Permission check failed";
|
||||||
|
|
||||||
|
$msg .= " ($what)" if $what;
|
||||||
|
|
||||||
|
my $exc = PVE::Exception->new("$msg\n", %$param);
|
||||||
|
|
||||||
|
my ($pkg, $filename, $line) = caller;
|
||||||
|
|
||||||
|
$exc->{filename} = $filename;
|
||||||
|
$exc->{line} = $line;
|
||||||
|
|
||||||
|
die $exc;
|
||||||
|
}
|
||||||
|
|
||||||
sub is_param_exc {
|
sub is_param_exc {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user