feat(up): serialize errors before passing them to storage plugins
This commit is contained in:
parent
3b2b21f729
commit
c1d55978d7
7 changed files with 43 additions and 26 deletions
|
|
@ -7,8 +7,18 @@ import {
|
|||
type EmigrateStorage,
|
||||
type LoaderPlugin,
|
||||
type StringOrModule,
|
||||
type SerializedError,
|
||||
} from './types.js';
|
||||
|
||||
export const serializeError = (error: Error): SerializedError => {
|
||||
return {
|
||||
name: error.name,
|
||||
message: error.message,
|
||||
stack: error.stack,
|
||||
cause: error.cause instanceof Error ? serializeError(error.cause) : error.cause,
|
||||
};
|
||||
};
|
||||
|
||||
export const isGeneratorPlugin = (plugin: any): plugin is GeneratorPlugin => {
|
||||
if (!plugin || typeof plugin !== 'object') {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue