Class ErrnoHandler
java.lang.Object
express.mvp.myra.transport.iouring.ErrnoHandler
Utility class for handling Linux errno codes in io_uring operations.
This class maps native Linux error codes to meaningful Java exceptions with actionable recovery hints. It is essential for debugging io_uring operations where completion queue entries (CQEs) return negative errno values on failure.
Common Error Scenarios
| Errno | Name | Meaning | Recovery |
|---|---|---|---|
| 11 | EAGAIN | Resource temporarily unavailable | Retry operation |
| 32 | EPIPE | Broken pipe | Reconnect |
| 104 | ECONNRESET | Connection reset by peer | Reconnect |
| 110 | ETIMEDOUT | Connection timed out | Check network, retry |
| 111 | ECONNREFUSED | Connection refused | Verify server running |
Usage Example
int result = LibUring.cqeGetRes(cqe);
if (result < 0) {
if (ErrnoHandler.isRetryable(result)) {
// Retry the operation
} else if (ErrnoHandler.isConnectionLost(result)) {
// Reconnect
} else {
throw ErrnoHandler.fromErrno(result, "send");
}
}
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic TransportExceptionCreates aTransportExceptionfrom an errno code with context.static booleanisConnectionLost(int errno) Checks if the errno indicates the connection was lost.static booleanisConnectionRefused(int errno) Checks if the errno indicates the connection was refused.static booleanisRetryable(int errno) Checks if the errno indicates a retryable (transient) error.
-
Method Details
-
fromErrno
Creates aTransportExceptionfrom an errno code with context.The exception message includes the operation name, error description, and actionable recovery hints for common errors.
- Parameters:
errno- the Linux errno value (may be negative, will be converted to absolute)operation- description of the failed operation (e.g., "send", "recv", "connect")- Returns:
- a TransportException with descriptive message and recovery hints
-
isRetryable
public static boolean isRetryable(int errno) Checks if the errno indicates a retryable (transient) error.Retryable errors are temporary conditions that may succeed on retry, such as resource temporarily unavailable or operation in progress.
- Parameters:
errno- the Linux errno value (may be negative)- Returns:
trueif the operation should be retried
-
isConnectionLost
public static boolean isConnectionLost(int errno) Checks if the errno indicates the connection was lost.Connection loss requires reconnection to recover. This includes broken pipe, connection reset, and timeout errors.
- Parameters:
errno- the Linux errno value (may be negative)- Returns:
trueif the connection was lost and reconnection is needed
-
isConnectionRefused
public static boolean isConnectionRefused(int errno) Checks if the errno indicates the connection was refused.Connection refused means no service is listening on the target port. This typically requires verifying the server is running before retrying.
- Parameters:
errno- the Linux errno value (may be negative)- Returns:
trueif the connection was refused
-