TLValueException Class Reference

Built-in exception for value errors. This exception can be thrown when a variable is expected to have a certain value or adhere to certain criteria, but it does not. More...

List of all members.

Public Member Functions

 __construct ($message, $gotVar, $varName)
 Construct a new ValueException.


Detailed Description

Built-in exception for value errors. This exception can be thrown when a variable is expected to have a certain value or adhere to certain criteria, but it does not.

Example:

 function setAge($age) {
   if ($age < 5 || $age > 120)) {
     throw new ValueException("Age too small or large", $age, "age");
   }
   print("You're age is $age");
 }
 function setEMail($address) {
   if (strpos("@", $address) === False) {
     throw new ValueException("Should contain '@' char", $address, "address");
 }
 setAge(3);
 setEmail("f dot boender at zx dot nl");

Results in:

 Uncaught exception 'ValueException' with message '$age(3): Age too small or large' in [stacktrace]
 Uncaught exception 'ValueException' with message '$address(f dot boender at zx dot nl): Should contain '@' char' in [stacktrace]
 

Definition at line 823 of file tlib.php.


Constructor & Destructor Documentation

TLValueException::__construct ( message,
gotVar,
varName 
)

Construct a new ValueException.

Parameters:
$message (string) The message which describes the value problem.
$gotVar (mixed) The variable you got which did not follow expectations.
$varName (string) The name of the variable (without the $ prepended) you got which did not follow expectations.

Definition at line 831 of file tlib.php.


The documentation for this class was generated from the following file:
Generated on Sun Sep 24 22:05:25 2006 for TLib-PHP by  doxygen 1.4.7