php4Exception.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. // global exception handler
  3. function reportExceptions ($code, $descr, $filename, $line)
  4. {
  5. // obey error_level set by system/user
  6. if (!($code & error_reporting())) {
  7. return;
  8. }
  9. // init a new error info object
  10. $error = new MessageException($code, $descr, $filename, $line, "AMFPHP_RUNTIME_ERROR");
  11. // add the error object to the body of the AMFObject
  12. $amfbody = new MessageBody(NULL, $GLOBALS['amfphp']['lastMethodCall']);
  13. MessageException::throwException($amfbody, $error);
  14. //$amfbody->setResults($error);
  15. if($GLOBALS['amfphp']['encoding'] == 'amf0' || $GLOBALS['amfphp']['encoding'] == 'amf3')
  16. {
  17. // build a new AMFObject
  18. $amfout = new AMFObject("");
  19. $amfout->addBody($amfbody);
  20. // Add the trace headers we have so far while we're at it
  21. debugFilter($amfout);
  22. // create a new serializer
  23. $serializer = new AMFSerializer();
  24. // serialize the data
  25. $data = $serializer->serialize($amfout);
  26. // send the correct header
  27. header('Content-type: application/x-amf');
  28. // flush the amf data to the client.
  29. print($data);
  30. // kill the system after we find a single error
  31. exit;
  32. }
  33. else
  34. {
  35. serializationAction($amfbody);
  36. print($amfbody->getResults());
  37. exit;
  38. }
  39. }
  40. set_error_handler("reportExceptions");
  41. ?>