public static function fail($n, $text, $file, $line, $ctx) { // set up pseudo call and response if (self::$resp === null) { self::$resp = new response($ctx); } // generate useful HTTP status switch ($n) { case 2: $status = 400; break; default: $status = 500; } $details = array('status' => $status, 'code' => $n, 'error' => $text, 'file' => $file, 'line' => $line, 'ctx' => $ctx); if (PRESTO_TRACE) { $details[PRESTO_TRACE_KEY] = Presto::trace_info(); } // build the resulting error object $details = json_encode((object) $details); error_log('FATAL: ' . json_encode(array($status, $details))); self::$resp->hdr($status); print $details; die; }