diff options
Diffstat (limited to 'plugins/API')
-rw-r--r-- | plugins/API/Renderer/Json.php | 8 | ||||
-rw-r--r-- | plugins/API/Renderer/Original.php | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/plugins/API/Renderer/Json.php b/plugins/API/Renderer/Json.php index e33b8b7ff9..d3c3a9ab42 100644 --- a/plugins/API/Renderer/Json.php +++ b/plugins/API/Renderer/Json.php @@ -39,7 +39,13 @@ class Json extends ApiRenderer { $exceptionMessage = str_replace(array("\r\n", "\n"), " ", $message); - $result = json_encode(array('result' => 'error', 'message' => $exceptionMessage)); + $data = array('result' => 'error', 'message' => $exceptionMessage); + + if ($this->shouldSendBacktrace()) { + $data['backtrace'] = $exception->getTraceAsString(); + } + + $result = json_encode($data); return $this->applyJsonpIfNeeded($result); } diff --git a/plugins/API/Renderer/Original.php b/plugins/API/Renderer/Original.php index fa6091686c..98a8971f35 100644 --- a/plugins/API/Renderer/Original.php +++ b/plugins/API/Renderer/Original.php @@ -29,10 +29,16 @@ class Original extends ApiRenderer public function renderException($message, $exception) { if ($this->shouldSerialize()) { - return serialize([ + $data = [ 'result' => 'error', 'message' => $message, - ]); + ]; + + if ($this->shouldSendBacktrace()) { + $data['backtrace'] = $exception->getTraceAsString(); + } + + return serialize($data); } throw $exception; |