Skip to main content

Error handling

import {
MineTechError, ApiError,
AuthenticationError, PermissionError, NotFoundError, ConflictError,
ValidationError, RateLimitError, ServerError,
ConnectionError, TimeoutError,
SignatureVerificationError, ConfigurationError,
} from '@minetech/node/errors';
ClassStatusRetried
ValidationError400, 422No
AuthenticationError401No
PermissionError403No
NotFoundError404No
ConflictError409No
RateLimitError429Yes
ServerError5xxYes
TimeoutErrorYes
ConnectionErrorYes
ConfigurationErrorThrown at construction

Every class is actually thrown by the SDK, and a test pins the status→class mapping — an instanceof check that compiles will match at runtime.

Fields

catch (error) {
if (error instanceof ApiError) {
error.status; // 403
error.code; // 'insufficient_scope'
error.requestId; // quote this to support
error.body; // parsed response body
error.headers;
}
}

ValidationError adds fieldErrors; RateLimitError adds retryAfterSeconds.

Retries happen first

By the time an error reaches you, retryable failures have already been retried with backoff and jitter. A ServerError in your catch means the server failed repeatedly, not once.