feat(plugin-tools): improve error serialization and let each storage plugin serialize errors themselves
This commit is contained in:
parent
09181f284d
commit
a79f8e8e37
6 changed files with 29 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { serializeError } from '@emigrate/plugin-tools';
|
||||
import { type SerializedError, type EmigrateStorage, type MigrationStatus } from '@emigrate/plugin-tools/types';
|
||||
|
||||
export type StorageFsOptions = {
|
||||
|
|
@ -26,7 +27,7 @@ export default function storageFs({ filename }: StorageFsOptions): EmigrateStora
|
|||
|
||||
let lastUpdate: Promise<void> = Promise.resolve();
|
||||
|
||||
const update = async (migration: string, status: MigrationStatus, error?: SerializedError) => {
|
||||
const update = async (migration: string, status: MigrationStatus, error?: Error) => {
|
||||
lastUpdate = lastUpdate.then(async () => {
|
||||
const history = await read();
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ export default function storageFs({ filename }: StorageFsOptions): EmigrateStora
|
|||
[migration]: {
|
||||
status,
|
||||
date: new Date().toISOString(),
|
||||
error,
|
||||
error: error ? serializeError(error) : undefined,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue