You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using conjure generated clients, any error is represented by a generic ConjureHTTPException that requires manual parsing to determine exactly what the error is. If I have some conjure error
I would like to get some generated python exception
classSomeException(Exception):
""" Something went wrong """NAMESPACE="MyService"ERROR_CODE="INVALID_ARGUMENT"# probably want this to be an enumERROR_NAME="MyService:SomeException"def__init__(self, conjure_exception: ConjureHTTPError):
# do some validationself.unsafe_args= ...
self.safe_args= ...
@staticmethoddefis_instance(self, conjure_exception: ConjureHTTPError) ->bool:
# check if the conjure exception is thisreturnconjure_exception.error_name==SomeException.ERROR_NAME
That way I can use this in my code to convert a ConjureHTTPError into a more user friendly exception, with some actual types
try:
returnsome_service.endpoint()
exceptConjureHTTPErroraserr:
ifSomeException.is_error(err):
actual_exception=SomeException(err)
raiseUserFriendlyError(actual_exception.safe_args.argument, actual_exception.object.some_object_field)
# maybe check some other exceptions here tooraiseerr
Both java and typescript conjure clients do this, I think it would be really useful to have it in python as well
The text was updated successfully, but these errors were encountered:
When using conjure generated clients, any error is represented by a generic
ConjureHTTPException
that requires manual parsing to determine exactly what the error is. If I have some conjure errorI would like to get some generated python exception
That way I can use this in my code to convert a ConjureHTTPError into a more user friendly exception, with some actual types
Both java and typescript conjure clients do this, I think it would be really useful to have it in python as well
The text was updated successfully, but these errors were encountered: