UNPKG

@fiberplane/hono-otel

Version:

Hono middleware to forward OpenTelemetry traces to a local instance of @fiberplane/studio

36 lines (35 loc) 1.42 kB
export function errorToJson(error) { return { name: error.name, // Includes the name of the error, e.g., 'TypeError' message: error.message, // The message string of the error stack: error.stack, // Stack trace of where the error occurred (useful for debugging) }; } /** * Quick and dirty type guard to check if an error is *likely* a NeonDbError */ export function isLikelyNeonDbError(error) { return (typeof error === "object" && error !== null && "name" in error && typeof error.name === "string" && "message" in error && typeof error.message === "string" && (!("sourceError" in error) || error.sourceError instanceof Error)); } export function neonDbErrorToJson(error) { return { name: error.name, message: error.message, sourceError: error.sourceError ? errorToJson(error.sourceError) : undefined, // NOTE - NeonDbError does not include a stack trace! https://github.com/neondatabase/serverless/issues/82 stack: error?.sourceError?.stack, // TODO - Figure out how to extract these fields from NeonDbError... // // where: error?.sourceError?.where, // table: error?.sourceError?.table, // column: error?.sourceError?.column, // dataType: error?.sourceError?.dataType, // internalQuery: error?.sourceError?.internalQuery, }; }