protected function getJsonMessage($exception)
    {
        $error = array(
            'message' => 'Application Error',
        );
        
        if ($this->options['display_details']) {
            $error['exception'] = array();
            
            do {
                $error['exception'][] = array(
                    'type' => get_class($exception),
                    'code' => $exception->getCode(),
                    'message' => $exception->getMessage(),
                    'file' => $exception->getFile(),
                    'line' => $exception->getLine(),
                    'trace' => explode("\n", $exception->getTraceAsString()),
                );
            } while ($exception = $exception->getPrevious());
        }
        
        return json_encode($error, JSON_PRETTY_PRINT);
    }