diff --git a/doc/70-REST-API.md b/doc/70-REST-API.md index 0a675bbb..dd5d2669 100644 --- a/doc/70-REST-API.md +++ b/doc/70-REST-API.md @@ -123,6 +123,7 @@ Icinga Objects | withServices | Show services attached to a host. `resolved` and `withNull` | | | are applied for services too | | allowOverrides | Set variable overrides for virtual Services | +| showStacktrace | Returns the related stack trace, in case an error occurs | #### Resolve object properties diff --git a/doc/82-Changelog.md b/doc/82-Changelog.md index e27f123c..8884dbc9 100644 --- a/doc/82-Changelog.md +++ b/doc/82-Changelog.md @@ -23,6 +23,7 @@ v1.10.0 (unreleased) ### REST API * FIX: addressing service templates by name has been fixed (#2487) +* FEATURE: Stack traces can now be requested (#2570) ### CLI * FIX: config deploy doesn't try to wait in case of no deployment (#2522) diff --git a/library/Director/RestApi/RequestHandler.php b/library/Director/RestApi/RequestHandler.php index b57e610a..6f668896 100644 --- a/library/Director/RestApi/RequestHandler.php +++ b/library/Director/RestApi/RequestHandler.php @@ -58,7 +58,11 @@ abstract class RequestHandler } $response->sendHeaders(); - $this->sendJson((object) ['error' => $message]); + $result = ['error' => $message]; + if ($this->request->getUrl()->getParam('showStacktrace')) { + $result['trace'] = $error->getTraceAsString(); + } + $this->sendJson((object) $result); } // TODO: just return json_last_error_msg() for PHP >= 5.5.0