refactor: dedupe runtime error formatting

This commit is contained in:
Peter Steinberger
2026-04-07 01:58:25 +01:00
parent 9b7c0bf8e9
commit d4360f8068
12 changed files with 26 additions and 17 deletions

View File

@@ -1,3 +1,4 @@
import { formatErrorMessage } from "../infra/errors.js";
import { runCommandWithTimeout } from "../process/exec.js";
export type PluginCommandRunResult = {
@@ -40,7 +41,7 @@ export async function runPluginCommandWithTimeout(
return {
code: 1,
stdout: "",
stderr: error instanceof Error ? error.message : String(error),
stderr: formatErrorMessage(error),
};
}
}

View File

@@ -1,4 +1,5 @@
import type { IncomingMessage, ServerResponse } from "node:http";
import { formatErrorMessage } from "../infra/errors.js";
import {
installRequestBodyLimitGuard,
isRequestBodyLimitError,
@@ -268,8 +269,7 @@ export async function readWebhookBodyOrReject(params: {
return respondWebhookBodyReadError({
res: params.res,
code: "INVALID_BODY",
invalidMessage:
params.invalidBodyMessage ?? (error instanceof Error ? error.message : String(error)),
invalidMessage: params.invalidBodyMessage ?? formatErrorMessage(error),
});
}
}