protected function returnFailure(Exception $exception, $withMessage=true)
    {
        $data = array();
        if ($withMessage) {
            $data['success'] = false;
            $data['errorCode'] = 500;
            $data['version'] = TAO_VERSION;
            if ($exception instanceof common_exception_UserReadableException) {
                $data['errorMsg'] = $exception->getUserMessage();
            } else {
                $this->logWarning(__CLASS__ . ' : ' . $exception->getMessage());
                $data['errorMsg'] = __('Unexpected error. Please contact administrator');
            }
        }

        $this->returnJson($data, 500);
        exit(0);
    }