Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,61 @@
|
||||
import { sanitizeErrorReportValue } from "./sanitize.js";
|
||||
|
||||
export type ErrorReportSeverity = "debug" | "info" | "warn" | "error" | "fatal";
|
||||
|
||||
export interface ErrorReportContext {
|
||||
component: string;
|
||||
operation: string;
|
||||
severity?: ErrorReportSeverity;
|
||||
requestId?: string;
|
||||
method?: string;
|
||||
path?: string;
|
||||
queueName?: string;
|
||||
jobId?: string | number;
|
||||
retryCount?: number;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface ErrorReportEvent extends ErrorReportContext {
|
||||
error?: unknown;
|
||||
errorName?: string;
|
||||
errorMessage?: string;
|
||||
errorStack?: string;
|
||||
}
|
||||
|
||||
export interface ErrorReporter {
|
||||
report(event: ErrorReportEvent): void | Promise<void>;
|
||||
}
|
||||
|
||||
export function createNoopErrorReporter(): ErrorReporter {
|
||||
return {
|
||||
report() {
|
||||
// Intentionally empty: the no-op reporter is safe for tests and local defaults.
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function reportError(reporter: ErrorReporter | undefined | null, event: ErrorReportEvent): void {
|
||||
if (!reporter) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = reporter.report(sanitizeErrorReportValue(event) as ErrorReportEvent);
|
||||
|
||||
if (isPromiseLike(result)) {
|
||||
result.catch(() => {
|
||||
// Reporter failures must never mask the runtime failure being reported.
|
||||
});
|
||||
}
|
||||
} catch {
|
||||
// Reporter failures must never mask the runtime failure being reported.
|
||||
}
|
||||
}
|
||||
|
||||
function isPromiseLike(value: unknown): value is PromiseLike<void> {
|
||||
return Boolean(value) && typeof (value as { catch?: unknown }).catch === "function";
|
||||
}
|
||||
|
||||
export { sanitizeErrorReportValue } from "./sanitize.js";
|
||||
export { createSentryErrorReporter, type SentryErrorReporterOptions, type SentryLikeModule, type SentryInitOptions } from "./sentry.js";
|
||||
export { initializeTracing, shutdownTracing, type TracingOptions, type NodeSdkLikeModule, type NodeSdkInstance, type OtlpExporterLikeModule } from "./tracing.js";
|
||||
Reference in new issue
Block a user