mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
chore(lint): enable stricter error rules
This commit is contained in:
@@ -534,7 +534,7 @@ async function requestDiscordJson<T>(params: {
|
||||
label: `${params.errorPrefix} ${params.method} ${redactDiscordApiPath(params.path)}`,
|
||||
signal: controller.signal,
|
||||
maxBytes: responseBodyMaxBytes,
|
||||
}).catch((error) => {
|
||||
}).catch((error: unknown) => {
|
||||
if (isTooLargeError(error)) {
|
||||
throw error;
|
||||
}
|
||||
@@ -1039,7 +1039,7 @@ async function main(): Promise<number> {
|
||||
return 0;
|
||||
}
|
||||
const result = await run().catch(
|
||||
(err): FailureResult => ({
|
||||
(err: unknown): FailureResult => ({
|
||||
ok: false,
|
||||
stage: "unexpected",
|
||||
smokeId: "n/a",
|
||||
|
||||
@@ -230,7 +230,7 @@ async function main() {
|
||||
idempotencyKey: randomUUID(),
|
||||
},
|
||||
(t.timeoutMs ?? 12_000) + 2_000,
|
||||
).catch((err) => {
|
||||
).catch((err: unknown) => {
|
||||
results.push({ id: t.id, ok: false, error: formatErr(err) });
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -474,9 +474,9 @@ async function smokeGoogleLiveBrowserWs(browser: Browser, apiKey: string): Promi
|
||||
}
|
||||
window.clearTimeout(timeout);
|
||||
resolve({ setupComplete: true, readyState: ws.readyState });
|
||||
})().catch((error) => {
|
||||
})().catch((error: unknown) => {
|
||||
window.clearTimeout(timeout);
|
||||
reject(error);
|
||||
reject(toLintErrorObject(error, "Non-Error rejection"));
|
||||
});
|
||||
});
|
||||
ws.addEventListener("error", () => {
|
||||
@@ -751,7 +751,7 @@ async function main(): Promise<void> {
|
||||
}
|
||||
|
||||
if (import.meta.url === pathToFileURL(process.argv[1] ?? "").href) {
|
||||
await main().catch((error) => {
|
||||
await main().catch((error: unknown) => {
|
||||
console.error(shortError(error));
|
||||
process.exitCode = 1;
|
||||
});
|
||||
@@ -763,3 +763,17 @@ export const testing = {
|
||||
readBoundedText,
|
||||
resolveOpenAIHttpTimeoutMs,
|
||||
};
|
||||
|
||||
function toLintErrorObject(value: unknown, fallbackMessage: string): Error {
|
||||
if (value instanceof Error) {
|
||||
return value;
|
||||
}
|
||||
if (typeof value === "string") {
|
||||
return new Error(value);
|
||||
}
|
||||
const error = new Error(fallbackMessage, { cause: value });
|
||||
if ((typeof value === "object" && value !== null) || typeof value === "function") {
|
||||
Object.assign(error, value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ async function main(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
main().catch((error: unknown) => {
|
||||
process.stderr.write(
|
||||
`${error instanceof Error ? error.stack || error.message : String(error)}\n`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user