I am creating a custom exception class which extends the default php Exception class and overloads the __toString() function.
By default, the PHP Exception class has a defined $code variable which is an INTEGER
The error codes i am using are in the format of 6xx.x
Because the default $code is defined as an integer, all my error codes come out as 6xx
Is it possible to overload it as a double or float?
Code: Select all
<?php
/**
* Define a custom exception class
*/
class EAPIException extends Exception{
public function __Construct($message, $code = 0) {
// construct the parent Exception class
parent::__Construct($message, $code);
}
// custom string representation of object
public function __toString() {
return "<pre>[{$this->code}]: {$this->message}\n</pre>";
}
}
?>