diff --git a/src/actions.ts b/src/actions.ts index ca0dcf0..31b182e 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -6,6 +6,7 @@ import { LogReturn, Logs } from "@ubiquity-os/ubiquity-os-logger"; import { config } from "dotenv"; import { CommentHandler } from "./comment"; import { Context } from "./context"; +import { transformError } from "./error"; import { customOctokit } from "./octokit"; import { verifySignature } from "./signature"; import { inputSchema } from "./types/input-schema"; @@ -96,16 +97,12 @@ export async function createActionsPlugin { + if (err instanceof LogReturn) { + return err.logMessage.raw; + } else if (err instanceof Error) { + return err.message; + } else { + return err; + } + }) + .join("\n\n"), + { error } + ); + } else if (error instanceof Error || error instanceof LogReturn) { + loggerError = error; + } else { + loggerError = context.logger.error(String(error)); + } + + return loggerError; +} diff --git a/src/server.ts b/src/server.ts index 65cb55e..e9930c3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,11 +1,12 @@ import { EmitterWebhookEventName as WebhookEventName } from "@octokit/webhooks"; import { Value } from "@sinclair/typebox/value"; -import { LogReturn, Logs } from "@ubiquity-os/ubiquity-os-logger"; +import { Logs } from "@ubiquity-os/ubiquity-os-logger"; import { Hono } from "hono"; import { env as honoEnv } from "hono/adapter"; import { HTTPException } from "hono/http-exception"; import { CommentHandler } from "./comment"; import { Context } from "./context"; +import { transformError } from "./error"; import { PluginRuntimeInfo } from "./helpers/runtime-info"; import { customOctokit } from "./octokit"; import { verifySignature } from "./signature"; @@ -101,12 +102,7 @@ export function createPlugin