Skip to content

Not detecting errors from server #44

@poplexity

Description

@poplexity

For example when fetching table rows, if you pass a bad value for scope (a bug with Name type that was fixed already caused this example), then the server has an error. This error does not get picked up in match against result here:

let response = match result.await {
Ok(response) => response,
Err(_) => return Err(ClientError::NETWORK("Failed to get table rows".into())),
};

So, it continues beyond that and then attempts to parse the JSON and extract table row response values from an error payload:

"{"code":500,"message":"Internal Service Error","error":{"code":3010000,"name":"chain_type_exception","what":"chain type exception","details":[{"message":"Could not convert scope string '.' to any of the following: uint64_t, valid name, or valid symbol (with or without the precision)","file":"chain_plugin.cpp","line_number":1483,"method":"convert_to_type"}]}}"

Which fails here:

let more = response_obj.get_bool("more")?;

Because more is None and so the error seems like a bad response but really the issue is that we aren't properly check the response to be an error.

The match above likely checks for http level failures, and in this case it's a healthy http response that contains an error payload. Need to figure out the right fields in an http response to check to see if the response is an error before we continue to treat it as a healthy response payload. HINT: Check how the antelope typescript library does it in WharfKit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions