i found the solution, making my error object a static class and properly calling static variables from another class did the trick, ie: found the docs I was looking for. here's the solution:
this keeps all my error messages in one place and throws the exception i want, here's the hierarchy of my objects.
ExceptionError
class ExceptionError
{
public static $FMANAGER_ZERO_PARAMETERS = "ERROR: FileManager.fileInclude, a parameter must be defined";
public static $CLASS_INCLUDE_ExceptionError = "FATAL ERROR: ExceptionError [object] cannot be found";
public static $CLASS_INCLUDE_FileManager = "FATAL ERROR: FileManager [object] cannot be found";
public static $CLASS_INCLUDE_Empty = "FATAL ERROR: Unknown [object] cannot be found";
}
FileManager
include("ExceptionError.inc");
if (!class_exists('ExceptionError')) {
echo ExceptionError::$CLASS_INCLUDE_ExceptionError;
exit();
}
class FileManager
{
public function fileInclude($file_path="") {
if ($file_path=="") {
throw new Exception(ExceptionError::$FMANAGER_ZERO_PARAMETERS);
}
}
}
index.php
$fm = new FileManager();
try {
$fm->fileInclude();
} catch (Exception $e) {
echo "Caught an exception error: ", $e->getMessage(), "\n";
}
the above results in echoing "Caught exception error: ERROR: FileManager.fileInclude, a parameter must be defined " because inside index.php, i did not give fileInclude a parameter.
Hope this helps someone out there.
Happy Coding.