cenobites / flask-jsonrpc

Basic JSON-RPC implementation for your Flask-powered sites

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parameters order for Error Exception Class

cel03 opened this issue · comments

Based on pull request 51 which allows setting a value for "data"...

The actual parameters order for Error Class is:

def __init__(self, message=None, code=None, data=None):

In order to set a value for "data" without setting the "message", we must adjust our code and use a named argument:

raise InvalidParamsError(data='This value cannot be an integer.')

But this module (flask-jsonrpc) still raises exceptions using positioned arguments, like:

InvalidRequestError('The method you are trying to access is not availble by GET requests')

It sets 'The method you are trying to access is not availble by GET requests' to message instead of data.

"data": null,
"message": "The method you are trying to access is not availble by GET requests",

While the correct should be:

"data": "The method you are trying to access is not availble by GET requests",
"message": "Invalid Request.",

So the problem is: should this module use named argument for setting data or should the Error class change the parameters order to data come first to messsage for the first argument be always a data by default?

Hi,

In new release (1.0.0) this was solve.

Thank you.