Skip to content

Errors

Every error zdate throws is a ZError. One class, a small set of codes, and a stable way to branch on them.

ts
import {ZError} from '@sajajs/zdate'

try {
    zdate(input)
} catch (error) {
    if (ZError.is(error, 'resolution')) {
        // repairable — see Repairing Timestamps
    }
}

Codes

CodeMeaningHTTP status
invalid_argumentA call was given an invalid value400
validationInput data failed validation422
resolutionThe timestamp requires explicit resolution — repairable via ZRepair400
out_of_rangeA value fell outside its supported range400
not_foundA requested resource does not exist404
conflictInput conflicts with itself (e.g., duplicate critical suffix tags)409
not_supportedThe operation is not supported500

Members

MemberDescription
ZError.is(error, code)Type guard: is this a ZError with the given code
codeThe ZErrorCode
messageDeveloper-facing detail
clientMessageA safe, generic message for end users
messageListIndividual issues when a failure has several

The resolution Code

'resolution' marks the repairable family: offset/zone disagreements, ambiguous wall times, nonexistent wall times, and weekday/date disagreements. One documented check covers all of them:

ts
if (ZError.is(error, 'resolution')) {
    const repaired = ZRepair.timestamp(input, policy, error)
}

See Repairing Timestamps for policies and examples.