Create RPC error

    :param id: Request ID
    :param error_msg: Error message
    :param warning: List of warnings to attach to the message
    :return: JSON RPC formatted dict
978777
def rpc_error(id: Union[str, int], error_msg: str,
              warnings: List[Any] = []) -> rpcq.messages.RPCError:
    
    return rpcq.messages.RPCError(
        jsonrpc='2.0',
        id=id,
        error=error_msg,
        warnings=[rpc_warning(warning) for warning in warnings])
725609
def _get_err(self, e, id=None, jsonrpc=DEFAULT_JSONRPC):
        
        # Do not respond to notifications when the request is valid.
        if not id \
                and not isinstance(e, ParseError) \
                and not isinstance(e, InvalidRequestError):
            return None

        respond = {'id': id}

        if isinstance(jsonrpc, int):
            # v1.0 requires result to exist always.
            # No error codes are defined in v1.0 so only use the message.
            if jsonrpc == 10:
                respond['result'] = None
                respond['error'] = e.dumps()['message']
            else:
                self._fill_ver(jsonrpc, respond)
                respond['error'] = e.dumps()
        else:
            respond['jsonrpc'] = jsonrpc
            respond['error'] = e.dumps()

        return respond
87786
def get_message_type_by_id(self, message_type_id):
        
        self._validate_uuid(message_type_id)

        url = "/notification/v1/message-type/{}".format(message_type_id)
        response = NWS_DAO().getURL(url, self._write_headers())
        if response.status != 200:
            raise DataFailureException(url, response.status, response.data)

        data = json.loads(response.data)
        return self._message_type_from_json(data.get("MessageType"))
1084271
def create(data=None, id=None, message=None):
        

        return Error(
            data=data,
            id=id,
            message=message,
        )
841063
def _error_message(self):
        
        body = self._deserialize()
        return body.get('message', body) if isinstance(body, dict) else body
56819
function createError (err, target) {
  return { status: 'error', target: target, message: err, timestamp: Date.now() }
}
1278390
function writeError(code, res, msg) {
	try{
		if (res.headerSent) {
			logger.error("header Sent:", res.req.method, res.req.originalUrl);
		}
		if (httpCodeMapping) {
			code = mapHttpStatusCode(code);
		}
		msg = msg instanceof Error ? msg.message : msg;
		addStrictTransportHeaders(res);
		setResponseNoCache(res);
		if (typeof msg === 'string') {
			var err = JSON.stringify({Severity: "Error", Message: msg});
			res.setHeader('Content-Type', 'application/json');
			res.setHeader('Content-Length', err.length);
			res.writeHead(code);
			res.end(err);
		} else {
			res.writeHead(code);
			res.end();
		}
	}catch(err){
		logger.error(res.req.originalUrl , err.message);
		throw err;
	}
}
1185184
def add_error_handler(self, error_input):
        

        if isinstance(error_input, dict):
            error_response = error_input.get('response', {})
            cerr = error_response.get('command_error', NoResponse)
            qerr = error_response.get('query_error', NoResponse)

            response_dict = {'command_error': cerr,
                             'query_error': qerr}

            register_list = error_input.get('status_register', [])

            for register_dict in register_list:
                query = register_dict['q']
                register = StatusRegister(register_dict)
                self._status_registers[to_bytes(query)] = register
                for key in register.keys():
                    self._error_map[key] = register

            queue_list = error_input.get('error_queue', [])

            for queue_dict in queue_list:
                query = queue_dict['q']
                err_queue = ErrorQueue(queue_dict)
                self._error_queues[to_bytes(query)] = err_queue

        else:
            response_dict = {'command_error': error_input,
                             'query_error': error_input}

        for key, value in response_dict.items():
            self._error_response[key] = to_bytes(value)
1084416
def json_error(code, message):
    """"""
    # Message can be an unserializable object.
    message = repr(message)
    return jsonify(dict(request=request.path, message=message)), code
1363495
def request_payload(cls, request, request_id):
        ''''''
        payload = {
            'jsonrpc': '2.0',
            'method': request.method,
        }
        # A notification?
        if request_id is not None:
            payload['id'] = request_id
        # Preserve empty dicts as missing params is read as an array
        if request.args or request.args == {}:
            payload['params'] = request.args
        return payload
585893
def rpc_reply(id: Union[str, int], result: Optional[object],
              warnings: Optional[List[Warning]] = None) -> rpcq.messages.RPCReply:
    
    warnings = warnings or []

    return rpcq.messages.RPCReply(
        jsonrpc='2.0',
        id=id,
        result=result,
        warnings=[rpc_warning(warning) for warning in warnings]
    )
1313005
def toDict(self, msg: Dict) -> Dict:
        

        if isinstance(msg, Request):
            tmsg = msg.as_dict
        elif hasattr(msg, "_asdict"):
            tmsg = dict(msg._asdict())
        elif hasattr(msg, "__dict__"):
            tmsg = dict(msg.__dict__)
        elif self.allowDictOnly:
            raise ValueError("Message cannot be converted to an appropriate "
                             "format for transmission")
        else:
            tmsg = msg
        return tmsg
1183607
def _get_error_message(self, response):
        """"""

        error_message = 'An error occurred processing your request.'
        try:
            content = response.json()
            # {"errors":[{"code":34,"message":"Sorry,
            # that page does not exist"}]}
            error_message = content['errors'][0]['message']
        except TypeError:
            error_message = content['errors']
        except ValueError:
            # bad json data from Twitter for an error
            pass
        except (KeyError, IndexError):
            # missing data so fallback to default message
            pass

        return error_message
151697
private String createErrorMsg(JspLineId jspLineId, int errorLineNr) {
        StringBuffer compilerOutput = new StringBuffer();

        if (jspLineId.getSourceLineCount() <= 1) {
			Object[] objArray = new Object[] { new Integer(jspLineId.getStartSourceLineNum()), jspLineId.getFilePath()};
			if (jspLineId.getFilePath().equals(jspLineId.getParentFile())) {
				compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number", objArray));  // Defect 211450
			}
			else {
				compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number.included.file", objArray));  // Defect 211450
			}
        }
        else {
			// compute exact JSP line number 
			int actualLineNum=jspLineId.getStartSourceLineNum()+(errorLineNr-jspLineId.getStartGeneratedLineNum());
			if (actualLineNum>=jspLineId.getStartSourceLineNum() && actualLineNum <=(jspLineId.getStartSourceLineNum() + jspLineId.getSourceLineCount() - 1)) {
				Object[] objArray = new Object[] { new Integer(actualLineNum), jspLineId.getFilePath()};
				if (jspLineId.getFilePath().equals(jspLineId.getParentFile())) {
					compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number", objArray));  // Defect 211450
				}
				else {
					compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.single.line.number.included.file", objArray));  // Defect 211450
				}
			}
			else {
				Object[] objArray = new Object[] {
					new Integer(jspLineId.getStartSourceLineNum()),
					new Integer((jspLineId.getStartSourceLineNum()) + jspLineId.getSourceLineCount() - 1),
					jspLineId.getFilePath()};
				if (jspLineId.getFilePath().equals(jspLineId.getParentFile())) {
					compilerOutput.append(separatorString+  // Defect 211450
						JspCoreException.getMsg(
							"jsp.error.multiple.line.number", objArray));
				}
				else {
					compilerOutput.append(separatorString+  // Defect 211450
						JspCoreException.getMsg(
							"jsp.error.multiple.line.number.included.file",objArray));
				}
			}
        }

		compilerOutput.append(separatorString+JspCoreException.getMsg("jsp.error.corresponding.servlet",new Object[] { jspLineId.getParentFile()}));  // Defect 211450
		    //152470 starts
	        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable(Level.FINER)) {
	            logger.logp(Level.FINER, CLASS_NAME, "createErrorMsg", "The value of the JSP attribute jdkSourceLevel is ["+ jdkSourceLevel +"]");
	        }
	        //152470 ends
        return compilerOutput.toString();
    }
1320455
def make_json_error(error):
    
    message = extract_error_message(error)
    status_code = extract_status_code(error)
    context = extract_context(error)
    retryable = extract_retryable(error)
    headers = extract_headers(error)

    # Flask will not log user exception (fortunately), but will log an error
    # for exceptions that escape out of the application entirely (e.g. if the
    # error handler raises an error)
    error_logger.debug("Handling {} error: {}".format(
        status_code,
        message,
    ))

    # Serialize into JSON response
    response_data = {
        "code": status_code,
        "context": context,
        "message": message,
        "retryable": retryable,
    }
    # Don't pass in the error schema because it will suppress any extra fields
    return dump_response_data(None, response_data, status_code, headers)
1149831
function createError (err, src) {
  return { status: 'error', src: src, message: err, timestamp: Date.now() }
}
1202167
def warning(request, message, extra_tags='', fail_silently=False, async=False):
    """"""
    if ASYNC and async:
        messages.debug(_get_user(request), message)
    else:
        add_message(request, constants.WARNING, message, extra_tags=extra_tags,
                    fail_silently=fail_silently)