diff --git a/src/error.php b/src/error.php index 0bf6805..04e2c40 100644 --- a/src/error.php +++ b/src/error.php @@ -65,10 +65,8 @@ public function get_array() { $response_part = array(); // the basics - if ($this->http_status) { - $status_message = errors::get_http_status_message($this->http_status); - $response_part['status'] = $status_message; - } + $status_message = errors::get_http_status_message($this->http_status); + $response_part['status'] = $status_message; $response_part['code'] = $this->error_message; // user guidance diff --git a/src/errors.php b/src/errors.php index a25b4c9..62cbe7f 100644 --- a/src/errors.php +++ b/src/errors.php @@ -186,11 +186,6 @@ public function fill_errors($errors) { * @todo hide exception meta data on production environments */ public function add_exception($exception=null, $friendly_message=null, $about_link=null) { - $previous_exception = $exception->getPrevious(); - if ($previous_exception) { - $this->add_exception($previous_exception); - } - $error_message = $exception->getMessage(); $error_status = $exception->getCode(); @@ -198,13 +193,9 @@ public function add_exception($exception=null, $friendly_message=null, $about_li $new_error->set_http_status($error_status); // meta data - $trace = $exception->getTrace(); - if ($trace) { - $new_error->add_meta('trace', $trace); - } - $file = $exception->getFile(); if ($file) { + $file = str_replace($_SERVER['DOCUMENT_ROOT'].'/', '', $file); $new_error->add_meta('file', $file); } @@ -213,7 +204,20 @@ public function add_exception($exception=null, $friendly_message=null, $about_li $new_error->add_meta('line', $line); } + $trace = $exception->getTrace(); + if ($trace) { + foreach ($trace as &$place) { + $place['file'] = str_replace($_SERVER['DOCUMENT_ROOT'].'/', '', $place['file']); + } + $new_error->add_meta('trace', $trace); + } + $this->add_error_object($new_error); + + $previous_exception = $exception->getPrevious(); + if ($previous_exception) { + $this->add_exception($previous_exception); + } } /**