]> git.proxmox.com Git - pve-common.git/commitdiff
overload cmp operator for PVE::Exception
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 13 Oct 2011 09:14:30 +0000 (11:14 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 13 Oct 2011 09:14:30 +0000 (11:14 +0200)
So that we can use ($err eq "timeout") like expressions.

data/PVE/Exception.pm

index b30d0eda0f55b59c2a27e793c133c2564d745e78..8004d0555221080675001b076e6c2cfc93b2b560 100755 (executable)
@@ -15,6 +15,11 @@ use HTTP::Status qw(:constants);
 @ISA = qw(Exporter);
 
 use overload '""' => sub {local $@; shift->stringify};
+use overload 'cmp' => sub {
+    my ($a, $b) = @_;
+    local $@;  
+    return "$a" cmp "$b"; # compare as string
+};
 
 @EXPORT_OK = qw(raise raise_param_exc);