ImportsourceController: error handling for json

This commit is contained in:
Thomas Gelf 2020-10-09 11:54:09 +02:00
parent b45d12a85a
commit 1705e2e3e5
1 changed files with 5 additions and 1 deletions

View File

@ -188,7 +188,11 @@ class ImportsourceController extends ActionController
$response->setHeader('Content-Type', 'application/json', true);
$response->setHeader('Content-disposition', "attachment; filename=$filename", true);
$response->sendHeaders();
$this->sendJson($this->getResponse(), $data);
try {
$this->sendJson($this->getResponse(), $data);
} catch (Exception $e) {
$this->sendJsonError($response, $e->getMessage());
}
// TODO: this is not clean
if (\ob_get_level()) {
\ob_end_flush();