From 3aaefc499d9948c2d3838d2f4a3427c94b9f3650 Mon Sep 17 00:00:00 2001 From: Lode Claassen Date: Fri, 12 Jun 2015 14:06:15 +0200 Subject: [PATCH 1/3] switches order of exception details for better readability --- src/errors.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/errors.php b/src/errors.php index a25b4c9..1433649 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,11 +193,6 @@ 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) { $new_error->add_meta('file', $file); @@ -213,7 +203,17 @@ public function add_exception($exception=null, $friendly_message=null, $about_li $new_error->add_meta('line', $line); } + $trace = $exception->getTrace(); + if ($trace) { + $new_error->add_meta('trace', $trace); + } + $this->add_error_object($new_error); + + $previous_exception = $exception->getPrevious(); + if ($previous_exception) { + $this->add_exception($previous_exception); + } } /** From 1a3b81ec999a47b2fad59fdfd5c2c30ce792af77 Mon Sep 17 00:00:00 2001 From: Lode Claassen Date: Fri, 12 Jun 2015 14:06:38 +0200 Subject: [PATCH 2/3] skip exception details everyone knows (document-root) --- src/errors.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/errors.php b/src/errors.php index 1433649..62cbe7f 100644 --- a/src/errors.php +++ b/src/errors.php @@ -195,6 +195,7 @@ public function add_exception($exception=null, $friendly_message=null, $about_li // meta data $file = $exception->getFile(); if ($file) { + $file = str_replace($_SERVER['DOCUMENT_ROOT'].'/', '', $file); $new_error->add_meta('file', $file); } @@ -205,6 +206,9 @@ public function add_exception($exception=null, $friendly_message=null, $about_li $trace = $exception->getTrace(); if ($trace) { + foreach ($trace as &$place) { + $place['file'] = str_replace($_SERVER['DOCUMENT_ROOT'].'/', '', $place['file']); + } $new_error->add_meta('trace', $trace); } From a0f7e45bd01cf560855d508da7379e343f859817 Mon Sep 17 00:00:00 2001 From: Lode Claassen Date: Fri, 12 Jun 2015 16:33:20 +0200 Subject: [PATCH 3/3] always include a status code in errors useful when an exception has no preset code --- src/error.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/error.php b/src/error.php index 9238e84..53a5038 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