mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-03 20:24:03 +00:00
chore(lint): enable stricter error rules
This commit is contained in:
@@ -964,8 +964,10 @@ async function main() {
|
||||
}
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
main().catch((error) => {
|
||||
console.error(error instanceof Error ? error.message : error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
main().catch(
|
||||
/** @param {unknown} error */ (error) => {
|
||||
console.error(error instanceof Error ? error.message : error);
|
||||
process.exitCode = 1;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,10 @@ export async function fetchProofComments({
|
||||
lastError = error;
|
||||
}
|
||||
}
|
||||
throw lastError ?? new Error("No GitHub token available for proof comment lookup.");
|
||||
throw toLintErrorObject(
|
||||
lastError ?? new Error("No GitHub token available for proof comment lookup."),
|
||||
"Non-Error thrown",
|
||||
);
|
||||
}
|
||||
|
||||
function isMainModule() {
|
||||
@@ -231,3 +234,17 @@ export const testing = {
|
||||
if (isMainModule()) {
|
||||
await main();
|
||||
}
|
||||
|
||||
function toLintErrorObject(value, fallbackMessage) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user