forest
forest copied to clipboard
Improve `INTERNAL_ERROR` in JSON-RPC server
`INTERNAL_ERROR` is suitable for e.g handler panic - treat it like HTTP `500 Internal Server Error `.
Use other error codes (outside of the -32000..=-32099 range), here.
OTOH, if lotus always just always returns INTERNAL_ERROR
, we might decide to copy that.
After this discussion, I'll leave this up to your judgement
Originally posted by @aatifsyed in https://github.com/ChainSafe/forest/pull/3943#discussion_r1494469217
Adding a link to the specification: https://www.jsonrpc.org/specification#error_object
Lotus doesn't always return INTERNAL_ERROR
e.g
In [15]: client["Filecoin.ChainGetTipSet"]([])
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[15], line 1
----> 1 client["Filecoin.ChainGetTipSet"]([])
File ~/chainsafe/forest/test.py:89, in _Method.__call__(self, *args)
87 error = json_rpc_response.pop("error", None)
88 if error is not None:
---> 89 raise RuntimeError(error)
91 return json_rpc_response["result"]
RuntimeError: {'code': 1, 'message': 'NewTipSet called with zero length array of blocks'}
This is not actionable, as we have to follow Lotus' lead. Closing.