You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/** RPA 业务错误分类(技术设计 §7.3 v0.6 */
export type RpaErrorCode =
| "QUOTE_ENTRY_UNAVAILABLE"
| "ADDRESS_SUGGESTION_NOT_FOUND"
| "PAGE_LOAD_TIMEOUT"
| "RPA_CAPTCHA"
| "STRUCT_CHANGE"
| "RPA_DATA_INVALID"
| "SESSION_EXPIRED"
| "CARRIER_NO_CAPACITY"
| "ADDRESS_NOT_SUPPORTED"
| "ADDRESS_NOT_CONFIRMED"
| "CARGO_NOT_COMMITTED"
| "CARGO_WEIGHT_MISMATCH"
| "CARGO_RESET_FAILED";
export class RpaError extends Error {
readonly code: RpaErrorCode;
readonly retryable: boolean;
readonly pauseWorker: boolean;
constructor(
code: RpaErrorCode,
message: string,
options?: { retryable?: boolean; pauseWorker?: boolean },
) {
super(message);
this.name = "RpaError";
this.code = code;
this.retryable = options?.retryable ?? true;
this.pauseWorker = options?.pauseWorker ?? false;
}
}
/** 不重试的错误码(含入口类错误 task-128 */
export const NO_RETRY_CODES: ReadonlySet<RpaErrorCode> = new Set([
"QUOTE_ENTRY_UNAVAILABLE",
"ADDRESS_SUGGESTION_NOT_FOUND",
"STRUCT_CHANGE",
"RPA_CAPTCHA",
"CARRIER_NO_CAPACITY",
"ADDRESS_NOT_SUPPORTED",
"ADDRESS_NOT_CONFIRMED",
"RPA_DATA_INVALID",
]);