Skip to main content

error_reply

Function error_reply 

Source
pub fn error_reply(id: &WireId<'_>, code: IrErrorCode, message: &str) -> Value
Expand description

A failed reply to the request with this id.

ยงExamples

use protocol_droid::domain::jsonrpc::reply::error_reply;
use protocol_droid::domain::ir::IrErrorCode;
use protocol_droid::domain::jsonrpc::WireId;

let id = WireId::Number(7);
let document = error_reply(&id, IrErrorCode::MethodNotFound, "no such method").to_string();

assert_eq!(
    document,
    r#"{"error":{"code":-32601,"message":"no such method"},"id":7,"jsonrpc":"2.0"}"#,
);