Commit 2b5fcd92 authored by Penny Leach's avatar Penny Leach
Browse files

exception handler now checks for defined('JSON') & behaves differently

accordingly
parent fe517036
......@@ -459,6 +459,17 @@ class MaharaException extends Exception {
public function handle_exception() {
if (!empty($this->log)) {
log_message($message, LOG_LEVEL_WARN, true, true, $this->getFile(), $this->getLine(), $this->getTrace());
}
if (defined('JSON')) { // behave differently
@header('Content-type: text/plain');
@header('Pragma: no-cache');
echo json_encode(array('error' => true, 'message' => $this->render_exception()));
exit;
}
$outputtitle = $this->get_string('title');
$outputmessage = $this->render_exception();
$message = strip_tags($outputmessage);
......@@ -495,9 +506,6 @@ $outputmessage
EOF;
}
// end of printing stuff to the screen...
if (!empty($this->log)) {
log_message($message, LOG_LEVEL_WARN, true, true, $this->getFile(), $this->getLine(), $this->getTrace());
}
die();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment