-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(devexp): make unexpected domain object errors more helpful
- Loading branch information
1 parent
54e43d7
commit 83c4215
Showing
3 changed files
with
30 additions
and
2 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 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,14 @@ | ||
/** | ||
* UnexpectedCodePath errors are used to indicate that we've reached a code path that should never have been reached | ||
* | ||
* Purpose of having a dedicated class for this type of error is to allow us to easily add metadata about what was going on when we reached this code path | ||
* - e.g., the variables in memory at the time | ||
*/ | ||
export class UnexpectedCodePathError extends Error { | ||
constructor(message: string, metadata?: Record<string, any>) { | ||
const fullMessage = `UnexpectedCodePath: ${message}${ | ||
metadata ? `\n\n${JSON.stringify(metadata)}` : '' | ||
}`; | ||
super(fullMessage); | ||
} | ||
} |