- Add smart JSON export/import with schema validation and deduplication - Add per-account proxy configurations (Issue #79) - Add advanced account sorting engine (Issues #126 & #99) - Add compact horizontal layout, AI credits, inline model visibility (Issues #145 & #134) - Add desktop push notifications for low quota (Issue #53) - Fix Arch Linux AUR process detection bug (Issue #117) - Default theme set to Dark Mode (it's better) - UI Polishing: Improved sort dropdown and symmetrical dialog layouts - Dev Mode: Resolved port conflicts and single-instance locks - Updated README and README.zh-CN with new features
38 lines
972 B
TypeScript
38 lines
972 B
TypeScript
export interface UpstreamErrorHeaders {
|
|
retryAfter?: string;
|
|
}
|
|
|
|
export class UpstreamRequestError extends Error {
|
|
readonly status?: number;
|
|
readonly headers?: UpstreamErrorHeaders;
|
|
readonly body?: string;
|
|
|
|
constructor(params: {
|
|
message: string;
|
|
status?: number;
|
|
headers?: UpstreamErrorHeaders;
|
|
body?: string;
|
|
}) {
|
|
super(params.message);
|
|
this.name = 'UpstreamRequestError';
|
|
|
|
if (params.status && typeof params.status !== 'number') {
|
|
throw new TypeError('status must be a number');
|
|
}
|
|
if (params.headers && typeof params.headers !== 'object') {
|
|
throw new TypeError('headers must be an object');
|
|
}
|
|
|
|
this.status = params.status;
|
|
this.headers = params.headers;
|
|
|
|
// Sanitize and limit body size
|
|
if (typeof params.body === 'string') {
|
|
const sanitized = params.body.replace(/<[^>]*>?/gm, '');
|
|
this.body = sanitized.substring(0, 1000);
|
|
} else {
|
|
this.body = undefined;
|
|
}
|
|
}
|
|
}
|