TimeoutException doesn't have a `type` to check what kind of timeout it was
Describe the bug
There are different types of timeout errors when running code. As described in the TimeoutException class:
class TimeoutException(SandboxException):
"""
Raised when a timeout occurs.
The [unavailable] exception type is caused by sandbox timeout.\n
The [canceled] exception type is caused by exceeding request timeout.\n
The [deadline_exceeded] exception type is caused by exceeding the timeout for process, watch, etc.\n
The [unknown] exception type is sometimes caused by the sandbox timeout when the request is not processed correctly.\n
"""
However, when catching one of these exceptions you have to parse the message to infer which of these it is. This is error-prone as you evolve the E2B SDK.
I need a way to check what kind of timeout to then decide what to do with it.
Currently, a sandbox Idle timeout message is:
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.27.0</center>
</body>
</html>
: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeout' when starting the sandbox or calling '.set_timeout' on the sandbox with the desired timeout.
While an execution timeout is "Execution timed out — the 'timeout' option can be used to increase this timeout"
To Reproduce Steps to reproduce the behavior:
Set very short timeouts of the different kinds and see the TimeoutExceptions being thrown.
Expected behavior A clear and concise description of what you expected to happen.
Should either raise different TimeoutException sub-classes, or the SandboxExceptions should have fields to make it easy to identify exactly what the issue was so the client can handle it properly without having to parse the message.
Additional context
E2B Py SDK v1.01
Hey @antonioalegria, we will be improving the timeout exceptions and adding more granular ones.
Thanks!
Any updates on this?
I'm also noticing the following TimeoutExceptions:
TimeoutException("Sandbox not found: This error is likely due to sandbox timeout. You can modify the sandbox timeout by passing 'timeout' when starting the sandbox or calling '.set_timeout' on the sandbox with the desired timeout.")
This doesn't seem like a timeout exception..