Allow to use custom error codes for unexpected errors
Any unexpected error is translated to ServerError with default error code:
https://github.com/cenobites/flask-jsonrpc/blob/a72a0c4ecaf4adce8086ea277161c35482e7ddcc/src/flask_jsonrpc/site.py#L146
It would be useful to convert, for example, JWTError (https://github.com/mattupstate/flask-jwt/blob/c27084114e258863b82753fc574a362cd6c62fcd/flask_jwt/init.py#L160) to ServerError with specific error code for easier and more deterministic (avoiding string comparison) error handling in frontend.
Changing
jsonrpc_error = ServerError(data={'message': str(e)})
into something similar to:
jsonrpc_error = self.make_unexpected_error(e)
could maybe work, if we then could specify custom handler for unexpected errors.
Maybe here, instead of creating an error handling by scratch, uses the Flask Error Handling: https://flask.palletsprojects.com/en/2.2.x/errorhandling/#error-handlers
I will check out how to use that, ;).