@@ -21,9 +21,11 @@ function main() {
2121 }
2222 $ path = str_replace ("\\" , "/ " , $ path );
2323 $ classShortName = $ path ;
24- $ path = getenv ("DOCUMENT_ROOT " ) . "/ " . $ path . ".php " ;
24+ $ docroot = getenv ("DOCUMENT_ROOT " );
25+ if (empty ($ docroot )) $ docroot = ". " ;
26+ $ path = $ docroot . "/ " . $ path . ".php " ;
2527 if (!file_exists ($ path )) {
26- throw new ClassNotFoundException ( $ classShortName );
28+ trigger_error ( " Class not found: " . $ classShortName, E_USER_ERROR );
2729 }
2830 require_once ($ path );
2931 });
@@ -45,7 +47,6 @@ function main() {
4547 header ($ key . ": " . $ val );
4648 }
4749 }
48- $ flags = (Common::isBrowser (getenv ("HTTP_USER_AGENT " )) ? JSON_PRETTY_PRINT : 0 );
4950 $ json = [
5051 "error " => [
5152 "exception " => (new ReflectionClass ($ e ))->getShortName (),
@@ -54,12 +55,14 @@ function main() {
5455 ],
5556 ];
5657 if (ini_get ("display_errors " )) {
57- $ json ["error " ]["file " ] = Common::stripLeftPattern ($ e ->getFile (), "/home/nginx/bnetdocs-dev " );
58+ $ json ["error " ]["file " ] = Common::stripLeftPattern (
59+ $ e ->getFile (), getenv ("DOCUMENT_ROOT " )
60+ );
5861 $ json ["error " ]["line " ] = $ e ->getLine ();
5962 }
6063 Logger::logMetric ("error_data " , json_encode ($ json , JSON_PRETTY_PRINT ));
6164 Logger::logException ($ e );
62- die (json_encode ($ json , $ flags ));
65+ die (json_encode ($ json , Common:: prettyJSONIfBrowser () ));
6366 });
6467
6568 set_error_handler (function ($ errno , $ errstr , $ errfile , $ errline , $ errcontext ){
@@ -70,7 +73,6 @@ function main() {
7073 header ("Content-Type: application/json;charset=utf-8 " );
7174 header ("Expires: 0 " );
7275 header ("Pragma: max-age=0 " );
73- $ flags = (Common::isBrowser (getenv ("HTTP_USER_AGENT " )) ? JSON_PRETTY_PRINT : 0 );
7476 $ json = [
7577 "error " => [
7678 "exception " => null ,
@@ -79,12 +81,14 @@ function main() {
7981 ];
8082 if (ini_get ("display_errors " )) {
8183 $ json ["error " ]["message " ] = $ errstr ;
82- $ json ["error " ]["file " ] = Common::stripLeftPattern ($ errfile , "/home/nginx/bnetdocs-dev " );
84+ $ json ["error " ]["file " ] = Common::stripLeftPattern (
85+ $ errfile , getenv ("DOCUMENT_ROOT " )
86+ );
8387 $ json ["error " ]["line " ] = $ errline ;
8488 }
8589 Logger::logMetric ("error_data " , json_encode ($ json , JSON_PRETTY_PRINT ));
8690 Logger::logError ($ errno , $ errstr , $ errfile , $ errline , $ errcontext );
87- die (json_encode ($ json , $ flags ));
91+ die (json_encode ($ json , Common:: prettyJSONIfBrowser () ));
8892 });
8993
9094 Logger::initialize ();
0 commit comments