LakeQL
  • Overview
Server Setup
  • Create Server
  • Define Config
  • Yoga Configuration
  • createLakeQLApp
Authentication
  • Authorization Model
  • JWT Authentication
  • Permissions
  • Scope Authorization
  • Trino User Impersonation
  • Debugging Identity
Schema Builder
  • Builder Configuration
  • Scalar Types
  • Comparison Types
  • Pagination
  • Input Validation
Customization
  • Custom Queries & Mutations
  • Extending Core
  • CORS Configuration
  • Error Handling
  • API Reference
GitHub
LakeQL
  1. API
  2. Customization
  3. Error Handling

On this page

  1. Error Mapping
  2. Server-Side Logging
  3. The onError Hook

Error Handling

How LakeQL maps, logs, and forwards errors.

LakeQL normalizes errors end to end. Adapters throw typed DataSourceErrors. The API maps them to GraphQL errors with a stable code and HTTP status, logs them server-side, and offers a hook to forward them to telemetry.

Error Mapping #

handleErrorResponse maps a DataSourceError to a GraphQLError by its category:

categoryCodeHTTP status
authPERMISSION_DENIED403
queryQUERY_ERROR400
networkNETWORK_ERROR502
timeoutTIMEOUT504
cancelledCANCELLED499
unsupportedUNSUPPORTED_OPERATION400
anything elseUNKNOWN500

Errors that are not a DataSourceError fall through to the UNKNOWN / 500 branch. This includes DataSourceValidationError, which is a plain Error subclass.

The original error is preserved on the GraphQL error so server-side logging and telemetry keep the full context.

Server-Side Logging #

A built-in Yoga plugin logs every execution error with a severity matched to its category. Network and timeout errors log at error level, auth and query errors at warn, and anything that is not a DataSourceError at error. This runs regardless of what the client sees, so operational issues stay visible in your logs.

The onError Hook #

Forward errors to external telemetry like OpenTelemetry, Sentry, or metrics without the package depending on any of them. Provide an onError hook on defineApiConfig:

1
2
3
4
5
6
7
8
const server = defineApiConfig({
  runtime,
  tokenResolver,
  onError: ({ error }) => {
    telemetry.recordException(error)
  },
})

The hook runs for every execution error after it is logged. Errors thrown by the hook itself are swallowed, so a telemetry failure never breaks a response. See ApiErrorHook and createErrorLoggingPlugin.

Previous page

CORS Configuration