code, $fault->getMessage(), $fault->file, $fault->line, 'AMFPHP_RUNTIME_ERROR'); } else { $code = "AMFPHP_RUNTIME_ERROR"; if($fault->getCode() != 0) { $code = $fault->getCode(); } $ex = new MessageException(E_USER_ERROR, $fault->getMessage(), $fault->getFile(), $fault->getLine(), $code); } MessageException::throwException($bodyObj, $ex); $output = '__amfphp_error'; } return $output; } /** * Builds a class using a class name * If there is a failure, catch the error and return to caller */ function buildClass(&$bodyObj, $className) { global $amfphp; if(isset($amfphp['classInstances'][$className])) { return $amfphp['classInstances'][$className]; } try { $construct = new $className($className); $amfphp['classInstances'][$className] = & $construct; } catch(Exception $fault) { //When constructing a class, getLine and getFile don't refer to the appropriate thing, //hence this hack $ex = new MessageException(E_USER_ERROR, $fault->getMessage(), $bodyObj->classPath, 'Undetermined line in constructor', 'AMFPHP_BUILD_ERROR'); MessageException::throwException($bodyObj, $ex); $construct = '__amfphp_error'; } return $construct; } /** * We are using a deferred metho call instead of directly * calling the method because of a strange bug with throwing exceptions within * an error handler which seems to break the convential rule for working with exceptions * Nesting function calls seems to solve the problem, but not nesting try...catch */ function deferredMethodCall(&$bodyObj, &$object, $method, $args) { try { $output = amfphp_method_call($bodyObj->className . '.' . $method, $args); /* if($object === NULL) { $output = call_user_func_array ($method, $args); } else { $output = call_user_func_array (array(&$object, $method), $args); } */ } catch(Exception $fault) { if(get_class($fault) == "VerboseException") { $ex = new MessageException($fault->code, $fault->getMessage(), $fault->file, $fault->line, 'AMFPHP_RUNTIME_ERROR'); } else { $code = "AMFPHP_RUNTIME_ERROR"; if($fault->getCode() != 0) { $code = $fault->getCode(); } $ex = new MessageException(E_USER_ERROR, $fault->getMessage(), $fault->getFile(), $fault->getLine(), $code); } $output = '__amfphp_error'; MessageException::throwException($bodyObj, $ex); } return $output; } /** * Include a class * If there is an error, catch and return to caller */ function includeClass(&$bodyObj, $location) { $included = false; try { include_once($location); $included = true; } catch(Exception $fault) { $included = false; if(get_class($fault) == "VerboseException") { $ex = new MessageException($fault->code, $fault->getMessage(), $fault->file, $fault->line, 'AMFPHP_INCLUDE_ERROR'); } else { $ex = new MessageException(E_USER_ERROR, $fault->getMessage(), $fault->getFile(), $fault->getLine(), 'AMFPHP_INCLUDE_ERROR'); } MessageException::throwException($bodyObj, $ex); } return $included; } } ?>