PintoError and carry a status and a code.
| Error | Status | Meaning |
|---|---|---|
NotFoundError | 404 | The pin, board, or user doesn’t exist. |
BlockedError | 403 | Pinterest blocked the request. |
RateLimitError | 429 | Throttled. Carries retryAfterMs. |
NetworkError | Network-level failure. Carries cause. | |
ParseError | The response couldn’t be parsed. |
errorForStatus is also exported.
Example
import {
PintoError,
NotFoundError,
BlockedError,
RateLimitError,
} from "@traceryn/pinto";
try {
await pinto.getPin(url);
} catch (err) {
if (err instanceof NotFoundError) {
// handle missing pin
} else if (err instanceof RateLimitError) {
// back off for err.retryAfterMs
} else if (err instanceof BlockedError) {
// cool this session down or rotate the pool slot
} else if (err instanceof PintoError) {
// err.status, err.code
}
}
