Baseflare provides three error classes exported fromDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/nickruigrok/baseflare/llms.txt
Use this file to discover all available pages before exploring further.
baseflare/values, each serving a distinct purpose. BaseflareError<T> is for application-level typed errors you throw intentionally in your function handlers — the structured data payload propagates to the client intact. ValidationError is thrown automatically by validators when input fails a type check, and surfaces to the client as a VALIDATION_ERROR response. SchemaError is thrown at startup by defineSchema() and defineTable() when the schema definition is structurally invalid. Understanding which error to use and when is key to building predictable, well-typed APIs with Baseflare.
Import
BaseflareError<T>
BaseflareError<T> extends the native Error class and carries a typed data payload that is propagated to the calling client. Throw it from any query, mutation, or action handler to signal a business-logic failure with structured information the client can inspect and act on.
Class signature:
The structured payload attached to the error. Any serialisable value is valid. When
data is a string and no explicit message is provided, the string is used as both the error message and the data payload.Optional human-readable error message. Defaults to the string value of
data (when data is a string) or "BaseflareError" otherwise.ValidationError
ValidationError is thrown automatically by the validator runtime when a value fails a type check. You will encounter it when calling .validate() directly, or when Baseflare validates query/mutation arguments before your handler runs. The path property identifies exactly which field failed.
Class signature:
The dot-notation path to the field that failed validation (e.g.,
"args.address.zip", "value[2]"). When validating a top-level value directly, path is "value".A human-readable description of the failure, prefixed with the formatted path. For example:
"Value must have length at least 1" or "args.email must be a string".SchemaError
SchemaError is thrown at application startup by defineSchema() and defineTable() when the schema definition contains a structural problem. Because schema errors are caught immediately on boot, they will never surface to end-users in a running deployment — they are programming mistakes to be fixed before deploying.
Class signature:
SchemaError:
- No tables defined in the schema
- Duplicate index name within a table
- Partition index defined on a non-scalar field (arrays, objects, and records cannot be partition keys)
- Reserved field names used (e.g.,
_id,_createdAt) - Reserved table names used
ErrorCode
ErrorCode is a plain object constant (not a TypeScript enum) whose values are the string codes used in RPC error responses. Every error response from a Baseflare API has the shape { error: { code: string, message: string } }.
The request is not authenticated — no valid session or token was provided.
The authenticated user does not have permission to perform the requested operation.
The requested document or resource does not exist.
A value failed schema or argument validation. The response will include the field path and a human-readable reason.
The schema definition is invalid. Only occurs at deploy or startup time.
A schema deployment or migration failed.
The operation conflicted with concurrent state (e.g., unique constraint violation).
An unexpected error occurred in the database layer.
A document in the database does not conform to the declared schema.
The requested feature or operation is not yet implemented.
An unexpected internal server error. The message is not leaked to the client.
ErrorCode constants in application code: