Skip to main content

Errors

import { CopyInkError, isCopyInkError } from 'copy-ink'

try {
await getCopy({ scope: 'about' })
} catch (cause) {
if (isCopyInkError(cause) && cause.code === 'NOT_SET_UP') {
// …
}
}

CopyInkError carries a machine-readable code and a details record alongside its message. Use isCopyInkError rather than instanceof — the library may be present more than once in a dependency tree.

Codes

CodeRaised when
CONFIG_INVALIDThe config failed validation, or credentials are missing
NOT_SET_UPSomething read content before setupCopyInk() ran
AMBIGUOUS_CONTENT_FILEA scope resolves to both x.yml and x/_index.yml
AMBIGUOUS_LOCALE_LAYOUTContent exists at the root and in a default-locale folder
INVALID_SCOPEA scope that escapes the content root, or is otherwise unusable
INVALID_FIELD_PATHA field path that is empty or malformed
MISSING_FIELDA field has no value and missingField is 'error'
UNKNOWN_LOCALEA locale not present in locales
UNKNOWN_COLLECTIONA collection name not declared in the config
UNKNOWN_ITEMAn item that does not exist and missingField is 'error'
DUPLICATE_SLUGItem creation would overwrite an existing slug
INVALID_SLUGA published slug that is not a-lowercase-slug
INVALID_CHANGEA publish request carried a change kind copy-ink does not know
UNSAFE_PATHA write that would land outside the repository
FIELD_LOCKEDAn edit targeted a field locked by _locked or editable: false
NOT_AUTHENTICATEDNo session, or a sign-in that could not be verified
NOT_AUTHORISEDA valid session whose user is not on the allowlist
STALE_BASEThe branch moved since the editor loaded
BACKEND_ERRORThe forge refused the write
UPLOAD_REJECTEDAn upload over maxUploadBytes, or from a disallowed host
YAML_INVALIDA content file could not be parsed

Over HTTP

The route handler maps them onto status codes:

CodeStatus
NOT_AUTHENTICATED401
NOT_AUTHORISED403
STALE_BASE409
BACKEND_ERROR502
any other CopyInkError400
anything else500

See the HTTP API.

CLI issues

The CLI does not throw for content problems — it collects Issue values and prints them:

interface Issue {
severity: 'error' | 'warning'
code: string
message: string
file?: string
line?: number
hint?: string
}

Issue codes are listed under check and doctor. A command exits 1 when any issue has severity error.