blueshoes php application framework and cms            core_lang
[ class tree: core_lang ] [ index: core_lang ] [ all elements ]

Class: Bs_Error

Source Location: /core/lang/Bs_Error.class.php

Class Overview


BS Error - BS Language Component(*).


Author(s):

Version:

  • 4.3.$Revision: 1.2 $ $Date: 2003/08/09 15:17:48 $

Copyright:

  • blueshoes.org

Methods


Inherited Variables

Inherited Methods


Class Details

[line 32]
BS Error - BS Language Component(*).

This is a basic set-/get- error class and (in this case) also a function-lib. The main idea it to have a global, central place to stack the errors that occure during execution of your code.

*) BS Language Components are collection of functiona and/or classes that are not inherited by Bs_Object AND are not dependent on any other class or libs that use Bs_Object (to avoid cyclic dependences).

For comfort some short hand function have been defined that base on this class.

  • bs_setError($msg, $msgType); // Push an error in the global error list
  • bs_getLastError(); // Get last error from the global error list
  • bs_getErrors(); // Get all errors as array of strings




Tags:

access:  public
pattern:  singleton: (pseudostatic)
static:  
version:  4.3.$Revision: 1.2 $ $Date: 2003/08/09 15:17:48 $
copyright:  blueshoes.org
author:  Sam Blum <at blueshoes dot org>


[ Top ]


Class Methods


method appendAlert [line 151]

void appendAlert( int $msg)

Very basic. Set/append an alert massage. (Puts the msg in a global buffer )

Used when a message has to be echo to the user at the ende of the PHP execution. (Usually a warning or so after rendering the page)




Parameters:

int   $msg  

[ Top ]

method getAlert [line 159]

string getAlert( [$readOnce $readOnce = TRUE])

Very basic. Get the alert massage AND delete the alert buffer. See setAlert()



Parameters:

$readOnce   $readOnce   bool (Set to FALSE if buffer should not be deleted)

[ Top ]

method getErrors [line 116]

array getErrors( )

Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.

See setError() for more details.




Tags:

return:  Vector-array of error-strings
usedby:  bs_getErrors()
static:  
see:  Bs_Error::setError(), Bs_Error::getLastError(), Bs_Error::getLastErrors(), Bs_Error::getErrors(), Bs_Error.class.php


[ Top ]

method getLastError [line 83]

string getLastError( )

Basic error handling: Get last error string from the global Bs_Error-error stack.

See setError() for more details.




Tags:

return:  Formated error string. The last error inserted by setError()
usedby:  bs_getLastError()
static:  
see:  Bs_Error::setError(), Bs_Error::getLastError(), Bs_Error::getLastErrors(), Bs_Error::getErrors(), Bs_Error.class.php


[ Top ]

method getLastErrors [line 96]

void getLastErrors( )

Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().

The idea here: Get an array of all errors that may have accumulated since the last getLastError() OR getLastErrors() call. This happens then when multiple calls to setError() happen before you have the chance to get the last error. (Usually the first error is the most interesting, while the others are usually error of errors).




Tags:



[ Top ]

method setAlert [line 150]

void setAlert( int $msg)

Very basic. Set/append an alert massage. (Puts the msg in a global buffer )

Used when a message has to be echo to the user at the ende of the PHP execution. (Usually a warning or so after rendering the page)




Parameters:

int   $msg  

[ Top ]

method setError [line 61]

void setError( string $msg, string $msgType, [int $line = 0], [string $func = ''], [string $file = ''])

Basic error handling: Push an error string on the global Bs_Error-error stack.

Bs_Object uses the global error stack of Bs_Error and supplies wrappers for use. This makes the code look more natural. E.g.


1 class Obj extends Bs_Object {
2 function foo() {
3 $o->setError("Test Error", "WARNING");
4 return FALSE;
5 }
6 }
7 // class Obj in action
8 $o = new Obj();
9 if (FALSE === $o->foo()) {echo $o->getLastError();}




Tags:



Parameters:

string   $msg   Any string.
string   $msgType   Any string, usually something like 'ERROR' or 'WARNING'.
int   $line   omit in PHP 4.3+ otherwise use PHP's __LINE__ constant.
string   $func   omit in PHP 4.3+ otherwise pass function name or use PHP's __FUNCTION__ constant.
string   $file   omit in PHP 4.3+ otherwise pass function name or use PHP's __FILE__ constant.

[ Top ]

method toHtml [line 137]

string toHtml( )

Dumps the content of the error list as HTML.



Tags:

access:  public


[ Top ]

method toTxt [line 126]

string toTxt( )

Dumps the content of the error list as string.



Tags:

access:  public


[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:08:57 +0100 by phpDocumentor 1.2.3