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
|
|
@ -1,6 +1,6 @@
|
|||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { getOrLoadPlugins, getOrLoadReporter, getOrLoadStorage } from '@emigrate/plugin-tools';
|
||||
import { getOrLoadPlugins, getOrLoadReporter, getOrLoadStorage, serializeError } from '@emigrate/plugin-tools';
|
||||
import {
|
||||
type LoaderPlugin,
|
||||
type MigrationFunction,
|
||||
|
|
@ -219,15 +219,16 @@ export default async function upCommand({
|
|||
finishedMigrations.push(finishedMigration);
|
||||
} catch (error) {
|
||||
const errorInstance = error instanceof Error ? error : new Error(String(error));
|
||||
const serializedError = serializeError(errorInstance);
|
||||
const duration = getDuration(start);
|
||||
const finishedMigration: MigrationMetadataFinished = {
|
||||
...migration,
|
||||
status: 'failed',
|
||||
duration,
|
||||
error: errorInstance,
|
||||
error: serializedError,
|
||||
};
|
||||
|
||||
await storage.onError(finishedMigration, errorInstance);
|
||||
await storage.onError(finishedMigration, serializedError);
|
||||
await reporter.onMigrationError?.(finishedMigration, errorInstance);
|
||||
|
||||
finishedMigrations.push(finishedMigration);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue