Appearance
Rule.io SDK / client/src / RuleApiError
Class: RuleApiError
Defined in: client/src/errors.ts:20
Custom error class for Rule.io API errors
Extends
Error
Constructors
Constructor
new RuleApiError(
message,statusCode,_requestId?):RuleApiError
Defined in: client/src/errors.ts:108
Parameters
message
string
statusCode
number
_requestId?
string
Deprecated
This parameter is ignored. requestId will be removed in the next major version.
Returns
RuleApiError
Overrides
Error.constructor
Properties
errorPercentCurrent?
optionalerrorPercentCurrent?:number
Defined in: client/src/errors.ts:103
The current observed error-rate, parsed from X-ErrorPercent-Current (v3 endpoints only).
undefined when the header is absent.
errorPercentLimit?
optionalerrorPercentLimit?:number
Defined in: client/src/errors.ts:95
The error-rate ceiling that, once crossed, triggers a rate-limit block. Parsed from X-ErrorPercent-Limit (v3 endpoints only). Rule.io's documented value is 49.
Consumer retry layers should treat this together with errorPercentCurrent — retrying after a 4xx counts toward the error-percent budget.
undefined when the header is absent.
rateLimitLimit?
optionalrateLimitLimit?:number
Defined in: client/src/errors.ts:72
Maximum requests permitted in the current rate-limit window (v3 endpoints only).
Sourced from RequestsCount-Allowed (the header v3 actually emits) or X-RateLimit-Limit (the documented name — used if Rule.io ever aligns).
undefined when neither header is present.
rateLimitRemaining?
optionalrateLimitRemaining?:number
Defined in: client/src/errors.ts:83
Remaining requests in the current rate-limit window (v3 endpoints only).
Sourced from X-RateLimit-Remaining if Rule.io ever ships it; otherwise computed as RequestsCount-Allowed − RequestsCount-Current (clamped to a non-negative integer).
undefined when no header data is available to derive the value.
requestId?
readonlyoptionalrequestId?:string
Defined in: client/src/errors.ts:106
Deprecated
This property is never populated. It will be removed in the next major version.
retryAfterSeconds?
optionalretryAfterSeconds?:number
Defined in: client/src/errors.ts:61
Seconds the server asks the client to wait before retrying, parsed from the Retry-After response header (v3 endpoints only).
Rule.io's rate-limit contract triggers on a 49% error rate, so retrying before this delay actively accelerates the block. Consumer retry layers should prefer this value over a local backoff guess.
Two input forms are accepted:
- integer seconds (per RFC 7231 / Rule.io's published docs)
YYYY-MM-DD HH:MM:SSwithout a timezone (the form Rule.io v3 actually emits on real 429s). The timestamp is interpreted asEurope/Stockholm(CET/CEST). The delta is computed by converting the responseDateheader to the same timezone so the fixed offset cancels; a DST transition within the retry window could still cause ±3600 s error.
RFC 7231 HTTP-date is not yet supported (TODO). Field is undefined when the header is absent or can't be parsed.
statusCode
statusCode:
number
Defined in: client/src/errors.ts:110
validationErrors?
optionalvalidationErrors?:RuleValidationErrors
Defined in: client/src/errors.ts:40
Field-level validation errors from the v3 API, if present.
When the API returns an errors object with field-specific messages, they are captured here for programmatic access.
Example
typescript
try {
await client.updateAutomail(id, data);
} catch (error) {
if (error instanceof RuleApiError && error.validationErrors) {
for (const [field, messages] of Object.entries(error.validationErrors)) {
console.log(`${field}: ${messages.join(', ')}`);
}
}
}Methods
isAuthError()
isAuthError():
boolean
Defined in: client/src/errors.ts:128
Check if this is an authentication error
Returns
boolean
isConflict()
isConflict():
boolean
Defined in: client/src/errors.ts:149
Check if this is a conflict error (resource already exists)
Returns
boolean
isNotFound()
isNotFound():
boolean
Defined in: client/src/errors.ts:135
Check if this is a not found error
Returns
boolean
isRateLimited()
isRateLimited():
boolean
Defined in: client/src/errors.ts:121
Check if this is a rate limiting error
Returns
boolean
isServerError()
isServerError():
boolean
Defined in: client/src/errors.ts:156
Check if this is a server error
Returns
boolean
isValidationError()
isValidationError():
boolean
Defined in: client/src/errors.ts:142
Check if this is a validation error
Returns
boolean