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
| Code | Meaning | HTTP status |
|---|---|---|
invalid_argument | A call was given an invalid value | 400 |
validation | Input data failed validation | 422 |
resolution | The timestamp requires explicit resolution — repairable via ZRepair | 400 |
out_of_range | A value fell outside its supported range | 400 |
not_found | A requested resource does not exist | 404 |
conflict | Input conflicts with itself (e.g., duplicate critical suffix tags) | 409 |
not_supported | The operation is not supported | 500 |
Members
| Member | Description |
|---|---|
ZError.is(error, code) | Type guard: is this a ZError with the given code |
code | The ZErrorCode |
message | Developer-facing detail |
clientMessage | A safe, generic message for end users |
messageList | Individual 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.
