Add stringifyError that is useful for logging e.g. Something went wrong, ${stringifyError(e)}

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-10-20 21:16:35 +02:00
parent b61c50a12f
commit 8c30ae8902
7 changed files with 63 additions and 21 deletions
@@ -20,7 +20,7 @@ import {
parseEntityRef,
UNSTABLE_EntityStatusItem,
} from '@backstage/catalog-model';
import { SerializedError } from '@backstage/errors';
import { SerializedError, stringifyError } from '@backstage/errors';
import { Knex } from 'knex';
import { uniqBy } from 'lodash';
import { v4 as uuid } from 'uuid';
@@ -49,7 +49,9 @@ export class Stitcher {
try {
await this.stitchOne(entityRef);
} catch (error) {
this.logger.error(`Failed to stitch ${entityRef}, ${error}`);
this.logger.error(
`Failed to stitch ${entityRef}, ${stringifyError(error)}`,
);
}
}
}