Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How are bad input parameters handled? #84

Open
marv-engine opened this issue Aug 1, 2014 · 4 comments
Open

How are bad input parameters handled? #84

marv-engine opened this issue Aug 1, 2014 · 4 comments

Comments

@marv-engine
Copy link

What does MasterCore do & return when an invalid value is passed as an input parameter, e.g. to one of the query api's? Is that detected as an error or does it just return nothing?

Is there a list of error codes and their meaning?

@zathras-crypto
Copy link

Each RPC call is an independent entity. The input parameters are checked, and RPC errors returned on bad values. Error codes are not unique at this stage, but the human readable errors describe the error. It is on the 'todo' list to go through every human readable error and assign unique error codes etc to these but not prioritized highly, as we're often moved onto new things as soon as something 'works' rather than 'finished'.

Thanks
Z

@zathras-crypto
Copy link

Example

    int64_t tmpPropertyId = params[0].get_int64();
    if ((1 > tmpPropertyId) || (4294967295 < tmpPropertyId)) // not safe to do conversion
            throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid property ID");

    unsigned int propertyId = int(tmpPropertyId);
    CMPSPInfo::Entry sp;
    if (false == _my_sps->getSP(propertyId, sp)) {
      throw JSONRPCError(RPC_INVALID_PARAMETER, "Property ID does not exist");
    }

@marv-engine
Copy link
Author

Got it. Thx.

@m21 m21 closed this as completed Sep 21, 2014
@dexX7
Copy link

dexX7 commented Sep 21, 2014

Slightly related: I think getXbalance should not throw exceptions, but rather respond with 0.0 or an empty array, if "address does not exist (for property N)", unless input format is wrong.

@m21 m21 reopened this Sep 21, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants