Errors, stopping and signing out
A command that fails throws a db.CommandError, with the server's message and a status:
| Status | When |
|---|---|
| 400 | the server cannot use the payload, a value or the query |
| 401 | there is no valid token |
| 403 | the user may not do this, for example when CmsApiOptions.Authorize refuses or a module is not active |
| 404 | the node does not exist |
| 409 | a conflict, such as a second published revision in one culture |
| 499 | the call was stopped through its signal; cancelled is set |
| 500 | anything else |
Every method that sends a command takes an AbortSignal last. Aborting it also stops the command on
the server:
let running: AbortController | null = null;
async function suggest(text: string) {
running?.abort(); // the user typed again
running = new AbortController();
return store.query(Page).where(n => n.Name.startsWith(text)).take(10).execute(running.signal);
}channel.onUnauthorized(handler) is called when the server refuses the token, because it expired or
its user was deleted. Sign in again, then call channel.connect() to open the stream again.