RequestHandler: optionally return stack traces

fixes #2570
This commit is contained in:
Thomas Gelf 2022-07-20 12:02:16 +02:00
parent b444ec0101
commit f1df0b6c7a
3 changed files with 7 additions and 1 deletions

View File

@ -123,6 +123,7 @@ Icinga Objects
| withServices | Show services attached to a host. `resolved` and `withNull` | | withServices | Show services attached to a host. `resolved` and `withNull` |
| | are applied for services too | | | are applied for services too |
| allowOverrides | Set variable overrides for virtual Services | | allowOverrides | Set variable overrides for virtual Services |
| showStacktrace | Returns the related stack trace, in case an error occurs |
#### Resolve object properties #### Resolve object properties

View File

@ -23,6 +23,7 @@ v1.10.0 (unreleased)
### REST API ### REST API
* FIX: addressing service templates by name has been fixed (#2487) * FIX: addressing service templates by name has been fixed (#2487)
* FEATURE: Stack traces can now be requested (#2570)
### CLI ### CLI
* FIX: config deploy doesn't try to wait in case of no deployment (#2522) * FIX: config deploy doesn't try to wait in case of no deployment (#2522)

View File

@ -58,7 +58,11 @@ abstract class RequestHandler
} }
$response->sendHeaders(); $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 // TODO: just return json_last_error_msg() for PHP >= 5.5.0