From 4e7d4378804d982105bd35cf43dc8c6dcb779521 Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Wed, 8 Nov 2023 16:09:18 +0000 Subject: [PATCH] [babel] Remove unused PipelineError Most of the use cases are already handled with ErrorSeverity.InvalidConfig --- .../src/Entrypoint/Options.ts | 5 ---- .../src/Entrypoint/Program.ts | 23 ++++--------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts index 438f918d5f..c8936f8032 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Options.ts @@ -138,11 +138,6 @@ export type LoggerEvent = fnLoc: t.SourceLocation | null; fnName: string | null; memoSlots: number; - } - | { - kind: "PipelineError"; - fnLoc: t.SourceLocation | null; - data: any; }; export type Logger = { diff --git a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts index 991f44b70a..ac03d0183d 100644 --- a/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts +++ b/compiler/packages/babel-plugin-react-forget/src/Entrypoint/Program.ts @@ -68,29 +68,14 @@ type CompileResult = { function handleError( pass: CompilerPass, fnLoc: t.SourceLocation | null, - err: unknown + err: CompilerError ): void { if (pass.opts.logger) { - if (err instanceof CompilerError) { - for (const detail of err.details) { - pass.opts.logger.logEvent(pass.filename, { - kind: "CompileError", - fnLoc, - detail: detail.options, - }); - } - } else { - let stringifiedError; - if (err instanceof Error) { - stringifiedError = err.stack ?? err.message; - } else { - stringifiedError = err?.toString() ?? "[ null ]"; - } - + for (const detail of err.details) { pass.opts.logger.logEvent(pass.filename, { - kind: "PipelineError", + kind: "CompileError", fnLoc, - data: stringifiedError, + detail: detail.options, }); } }