raise translate_boto_error(captured_error) from captured_error is a common pattern in the codebase, though the problem with this is that translate_boto_error might return the same exception and it would create a recursion of __cause__ since x_exception.__cause__ is itself (is x_exception) which would prevent anyone from traversing it easily;
https://github.com/dask/s3fs/blob/1333a8d46d38fd8d4c85536972cafcba998fd62e/s3fs/core.py#L253
This pattern can be replaced via
new_exc = translate_boto_error(exc)
if new_exc is exc:
raise exc
else:
raise new_exc from exc
but since it would create a lot of code duplication, I think a better way would be directly using raise translate_boto_error(exc) directly and setting the __cause__ there to the new exception so that we can avoid the recursion and also the code duplication at the same time.
raise translate_boto_error(captured_error) from captured_erroris a common pattern in the codebase, though the problem with this is thattranslate_boto_errormight return the same exception and it would create a recursion of__cause__sincex_exception.__cause__is itself (is x_exception) which would prevent anyone from traversing it easily;https://github.com/dask/s3fs/blob/1333a8d46d38fd8d4c85536972cafcba998fd62e/s3fs/core.py#L253
This pattern can be replaced via
but since it would create a lot of code duplication, I think a better way would be directly using
raise translate_boto_error(exc)directly and setting the__cause__there to the new exception so that we can avoid the recursion and also the code duplication at the same time.