[pve-devel] r5025 - pve-common/trunk
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Aug 17 12:19:33 CEST 2010
Author: dietmar
Date: 2010-08-17 10:19:33 +0000 (Tue, 17 Aug 2010)
New Revision: 5025
Modified:
pve-common/trunk/ChangeLog
pve-common/trunk/Exception.pm
Log:
Modified: pve-common/trunk/ChangeLog
===================================================================
--- pve-common/trunk/ChangeLog 2010-08-17 07:13:16 UTC (rev 5024)
+++ pve-common/trunk/ChangeLog 2010-08-17 10:19:33 UTC (rev 5025)
@@ -1,3 +1,7 @@
+2010-08-17 Proxmox Support Team <support at proxmox.com>
+
+ * Exception.pm (raise_param_exc): new helper function
+
2010-08-16 Proxmox Support Team <support at proxmox.com>
* Tools.pm (run_command): remove 'ticket' parameter - I think we
Modified: pve-common/trunk/Exception.pm
===================================================================
--- pve-common/trunk/Exception.pm 2010-08-17 07:13:16 UTC (rev 5024)
+++ pve-common/trunk/Exception.pm 2010-08-17 10:19:33 UTC (rev 5025)
@@ -10,12 +10,13 @@
use vars qw(@ISA @EXPORT_OK);
require Exporter;
use Storable qw(dclone);
+use HTTP::Status qw(:constants);
@ISA = qw(Exporter);
use overload '""' => sub {local $@; shift->stringify};
- at EXPORT_OK = qw(raise);
+ at EXPORT_OK = qw(raise raise_param_exc);
sub new {
my ($class, $msg, %param) = @_;
@@ -47,6 +48,21 @@
die $exc;
}
+sub raise_param_exc {
+ my $errors = @_;
+
+ my $exc = PVE::Exception->new("Parameter verification failed.\n",
+ code => HTTP_BAD_REQUEST,
+ errors => $errors);
+
+ my ($pkg, $filename, $line) = caller;
+
+ $exc->{filename} = $filename;
+ $exc->{line} = $line;
+
+ die $exc;
+}
+
sub stringify {
my $self = shift;
More information about the pve-devel
mailing list