feat(plugin-tools): improve error serialization and let each storage plugin serialize errors themselves

This commit is contained in:
Joakim Carlstein 2023-12-12 15:32:58 +01:00
parent 09181f284d
commit a79f8e8e37
6 changed files with 29 additions and 10 deletions

View file

@ -20,7 +20,7 @@ import {
type GenerateMigrationFunction,
type GeneratorPlugin,
} from '@emigrate/plugin-tools/types';
import { getTimestampPrefix, sanitizeMigrationName } from '@emigrate/plugin-tools';
import { getTimestampPrefix, sanitizeMigrationName, serializeError } from '@emigrate/plugin-tools';
const defaultTable = 'migrations';
@ -213,7 +213,7 @@ export const createMysqlStorage = ({ table = defaultTable, connection }: MysqlSt
status: row.status,
date: new Date(row.date),
// FIXME: Migrate the migrations table to support the error column
error: row.status === 'failed' ? new Error('Unknown error reason') : undefined,
error: row.status === 'failed' ? serializeError(new Error('Unknown error reason')) : undefined,
};
}
},