From aed8f7f12f1d0c691a6c4e80c2e50f253c4fcf06 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 16 Dec 2020 22:27:11 +0100 Subject: [PATCH] scaffolder-backend: clarify type detection error message --- .changeset/warm-moose-applaud.md | 5 +++++ .../src/scaffolder/stages/prepare/preparers.ts | 12 +++++++++++- .../src/scaffolder/stages/publish/publishers.ts | 12 +++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .changeset/warm-moose-applaud.md diff --git a/.changeset/warm-moose-applaud.md b/.changeset/warm-moose-applaud.md new file mode 100644 index 0000000000..70ae20711a --- /dev/null +++ b/.changeset/warm-moose-applaud.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Clearer error message when preparer or publisher type can't be determined. diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/preparers.ts b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/preparers.ts index 226f7e3836..84be130b79 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/prepare/preparers.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/prepare/preparers.ts @@ -50,7 +50,17 @@ export class Preparers implements PreparerBuilder { if (detected) { return detected; } - throw new Error(`No preparer integration found for url "${location}"`); + if (type) { + throw new Error( + `No preparer configuration available for type '${type}' with url "${location}". ` + + "Make sure you've added appropriate configuration in the 'scaffolder' configuration section", + ); + } else { + throw new Error( + `Failed to detect preparer type. Unable to determine integration type for location "${location}". ` + + "Please add appropriate configuration to the 'integrations' configuration section", + ); + } } throw new Error(`No preparer registered for type: "${protocol}"`); } diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts b/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts index 961fc45cae..03a4e884ba 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/publish/publishers.ts @@ -51,7 +51,17 @@ export class Publishers implements PublisherBuilder { if (detected) { return detected; } - throw new Error(`No preparer integration found for url "${location}"`); + if (type) { + throw new Error( + `No publisher configuration available for type '${type}' with url "${location}". ` + + "Make sure you've added appropriate configuration in the 'scaffolder' configuration section", + ); + } else { + throw new Error( + `Failed to detect publisher type. Unable to determine integration type for location "${location}". ` + + "Please add appropriate configuration to the 'integrations' configuration section", + ); + } } throw new Error(`No publisher registered for type: "${protocol}"`); }