Skip to main content

Overview

The III SDK provides structured error handling across function invocations, WebSocket connections, and trigger registrations. Understanding error types and handling patterns ensures robust distributed applications.

Error Types

Invocation Errors

When calling remote functions, the SDK returns structured error objects:

Registration Errors

Trigger Registration Errors

Function Handler Error Handling

Try/Catch in Handlers

1

Wrap handler logic in try/catch

Catch errors inside your function handlers to return meaningful responses:
2

Log errors with context

Use the context logger to attach trace IDs and span IDs automatically:

Uncaught Errors

If a handler throws an uncaught error, the SDK automatically catches it and returns an error response to the caller:

Invocation Error Handling

Configuring Timeouts

Handling Connection Errors

Best Practices

Error Handling Checklist:
  • ✅ Always validate input at the start of handlers
  • ✅ Use structured error responses (not just strings)
  • ✅ Log errors with context using ctx.logger.error()
  • ✅ Set appropriate timeouts for long-running operations
  • ✅ Handle connection state changes for resilience
  • ✅ Record exceptions in spans for distributed tracing
  • ✅ Differentiate between client errors (4xx) and server errors (5xx)

Graceful Degradation

Shutdown Error Handling