# Migrating from 1.0.0-alpha.325 ## An error is `new Error('CODE', { cause })` An operation refused by returning an `Error` with a `code` property, and whatever else was enumerable on it reached the caller. The code is the error's message now, and `cause` is the only other thing that travels: ```javascript // before return new (class extends Error { code = 'LOCKED' message = 'Locked until the new year' until = '2026-01-01' })() // after return new Error('LOCKED', { cause: { until: '2026-01-01' } }) ``` An `Error` returned with an empty message — which is what the class above is, once its `message` field is gone — is an exception, in every environment. A caller reads `code` and `cause`. `message` repeats the code, and no other property is there: ```javascript if (reply instanceof Error && reply.code === 'LOCKED') reply.cause.until ``` `cause` travels as JSON, so it is a value JSON can hold. ## A code is a string `errors` in a manifest lists strings. An integer code is written as one: ```yaml errors: ['0'] # was [0] ``` ## `RemoteError` is `CodedError` ```typescript import type { CodedError } from '@toa.io/core/types' // was RemoteError ``` `toa types` writes the new name, so generated types follow by running it. ## A refusal over HTTP is `{ code, cause }` The `422` body carried the error's enumerable properties, `message` among them where it was declared. It carries `code`, and `cause` where the operation gave one. The errors of the components Toa ships — identity, octets, configuration — have no text any more: a client reads the code. Where the gateway answered an octets upload, a JSON-RPC call or an MCP tool call with an error's message, it answers with its code. ## A set is bounded A call to a transition or an effect over `entries` names its set by `ids`, or bounds it by `limit`. One that does neither read every entry its criteria matched, and is refused: ```javascript // before await context.local.expire({ query: { criteria: 'due<1700000000000' } }) // after await context.local.expire({ query: { criteria: 'due<1700000000000', limit: 256 } }) ``` A `limit` of zero, which read everything, is refused. Where there may be more than the limit, call again until the set comes back short. An observation over `entries` called with `ids` no longer needs a `limit`. A route to a transition or an effect over `entries` is paged as a route to an observation is: it reads ten entries unless it declares or receives a `limit`. ## `omit` requires `sort` A query with `omit` and no `sort` is refused, and over HTTP answered `400`: pages of an unordered set repeat and miss entries. Order what is paged: ```yaml GET: endpoint: enumerate query: sort: title:asc ``` ## What to do 1. Rewrite every returned error as `new Error('CODE')`, moving what else it carried into `cause`. 2. Where a caller read a property of an error, read it from `cause`. 3. Write integer codes in `errors` as strings. 4. Replace `RemoteError` with `CodedError`, and run `toa types`. 5. Where an HTTP client read `message` from a `422`, read `code`. 6. Give every call to a transition or an effect over `entries` a `limit`, unless it carries `ids`. 7. Give every query that carries `omit` a `sort`, and every route that is paged by it.