-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): Consolidate path-related errors in Sentry (no-changel…
…og) (#7757) Keep reporting [path-related errors](https://n8nio.sentry.io/issues/4649493725) in Sentry but consolidate them in a single error group. Also, add `options.extra` as `meta` so they remain visible in debug logs: ``` 2023-11-24T11:50:54.852Z | error | ReportableError: Something went wrong "{ test: 123, file: 'LoggerProxy.js', function: 'exports.error' }" ``` --------- Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
- Loading branch information
Showing
9 changed files
with
62 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ReportableError } from 'n8n-workflow'; | ||
|
||
abstract class FileSystemError extends ReportableError { | ||
constructor(message: string, filePath: string) { | ||
super(message, { extra: { filePath } }); | ||
} | ||
} | ||
|
||
export class FileNotFoundError extends FileSystemError { | ||
constructor(filePath: string) { | ||
super('File not found', filePath); | ||
} | ||
} | ||
|
||
export class BinaryFileNotFoundError extends FileNotFoundError {} | ||
|
||
export class InvalidPathError extends FileSystemError { | ||
constructor(filePath: string) { | ||
super('Invalid path detected', filePath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { BinaryFileNotFoundError, FileNotFoundError, InvalidPathError } from './filesystem.errors'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { ReportableError } from './reportable.error'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Event } from '@sentry/node'; | ||
|
||
type Level = 'warning' | 'error' | 'fatal'; | ||
|
||
export type ReportingOptions = { | ||
level?: Level; | ||
} & Pick<Event, 'tags' | 'extra'>; | ||
|
||
export type ReportableErrorOptions = Partial<ErrorOptions> & ReportingOptions; | ||
|
||
export class ReportableError extends Error { | ||
readonly level: Level; | ||
|
||
readonly tags?: Event['tags']; | ||
|
||
readonly extra?: Event['extra']; | ||
|
||
constructor(message: string, { level, tags, extra, ...rest }: ReportableErrorOptions) { | ||
super(message, rest); | ||
this.level = level ?? 'error'; | ||
this.tags = tags; | ||
this.extra = extra; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters