Error handling

By calling ECODE, DCODE, and PCODE, you can obtain additional information about mitumJS's own errors and errors from nodes for debugging.

ECODE

This is an error defined by mitumJS, and mainly occurs when there is a problem with the function argument input value.

console.log(mitum.ECODE);
// output
{
    NO_API: "EC_NO_API",    
    UNKNOWN: "EC_UNKNOWN",
    EMPTY_STRING: "EC_EMPTY_STRING",
    EMPTY_SIGN: "EC_EMPTY_SIGN",
    INVALID_DATE: "EC_INVALID_DATE",
    INVALID_IP: "EC_INVALID_IP",
    INVALID_LENGTH: "EC_INVALID_LENGTH",
    INVALID_SEED: "EC_INVALID_SEED",
    INVALID_KEY: "EC_INVALID_KEY",
    INVALID_KEYS: "EC_INVALID_KEYS",
    ...
}

DCODE, PCODE:

This is an error that classifies the reason why the node “rejected” the transaction when “POST” a transaction to the blockchain and defines an additional explanation.

console.log(mitum.PCODE);
// output
{
    AMBIGUOUS: {
        code: "P0A",
        keyword: [""],
        description: "Ambiguous error",
        subject: "",
    },
    MITUM_CORE: {
        code: "P0M",
        keyword: [""],
        description: "Error from Mitum core",
        subject: "",
    },
    UNDEFINED: {
        code: "P00",
        keyword: [""],
        description: "Undefined error",
        subject: "",
    },
    ...
}

console.log(mitum.DCODE);
// output
{
    AMBIGUOUS: {
        code: "D00A",
        keyword: [""],
        description: "Ambiguous error",
        subject: "",
    },
    COMPLEX: {
        code: "D00C",
        keyword: [""],
        description: "Complex error with multiple DCODE",
        subject: "",
    },
    OP_DEP: {
        code: "D00D",
        keyword: [""],
        description: "Operation dependent error",
        subject: "",
    },
    ...
}

Last updated