better 'missing annotation' error messages

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2022-02-25 13:56:18 +01:00
parent fb3dc9d407
commit cb09096607
2 changed files with 9 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-catalog-backend': patch
---
Tweaked the wording of the "does not have a location" errors to include the actual missing annotation name, to help users better in fixing their inputs.
@@ -37,7 +37,9 @@ export function getEntityLocationRef(entity: Entity): string {
const ref = entity.metadata.annotations?.[ANNOTATION_LOCATION];
if (!ref) {
const entityRef = stringifyEntityRef(entity);
throw new InputError(`Entity '${entityRef}' does not have a location`);
throw new InputError(
`Entity '${entityRef}' does not have the annotation ${ANNOTATION_LOCATION}`,
);
}
return ref;
}
@@ -47,7 +49,7 @@ export function getEntityOriginLocationRef(entity: Entity): string {
if (!ref) {
const entityRef = stringifyEntityRef(entity);
throw new InputError(
`Entity '${entityRef}' does not have an origin location`,
`Entity '${entityRef}' does not have the annotation ${ANNOTATION_ORIGIN_LOCATION}`,
);
}
return ref;