[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1210] trunk/LedgerSMB.pm



Revision: 1210
          http://svn.sourceforge.net/ledger-smb/?rev=1210&view=rev
Author:   einhverfr
Date:     2007-05-18 15:03:25 -0700 (Fri, 18 May 2007)

Log Message:
-----------
LedgerSMB::error() to be replaced by a simple interface to an error class

Modified Paths:
--------------
    trunk/LedgerSMB.pm

Modified: trunk/LedgerSMB.pm
===================================================================
--- trunk/LedgerSMB.pm	2007-05-18 18:54:37 UTC (rev 1209)
+++ trunk/LedgerSMB.pm	2007-05-18 22:03:25 UTC (rev 1210)
@@ -521,6 +521,37 @@
     $date;
 }
 
+# To be replaced with a generic interface to an Error class
+sub error {
+
+    my ( $self, $msg ) = @_;
+
+    if ( $ENV{GATEWAY_INTERFACE} ) {
+
+        $self->{msg}    = $msg;
+        $self->{format} = "html";
+        $self->format_string('msg');
+
+        delete $self->{pre};
+
+        if ( !$self->{header} ) {
+            $self->header;
+        }
+
+        print
+          qq|<body><h2 class="error">Error!</h2> <p><b>$self->{msg}</b></body>|;
+
+        exit;
+
+    }
+    else {
+
+        if ( $ENV{error_function} ) {
+            &{ $ENV{error_function} }($msg);
+        }
+        die "Error: $msg\n";
+    }
+}
 # Database routines used throughout
 
 sub db_init {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.