Skip to content

Commit

Permalink
[INTERNAL] taskRepository: Helpful error message when retrieving remo…
Browse files Browse the repository at this point in the history
…ved tasks
  • Loading branch information
RandomByte committed Dec 23, 2021
1 parent 0cc9a8b commit bb0a01c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/tasks/taskRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ function getTask(taskName) {
const taskInfo = taskInfos[taskName];

if (!taskInfo) {
if (["createDebugFiles", "uglify"].includes(taskName)) {
throw new Error(
`Standard task ${taskName} has been removed in UI5 Tooling 3.0. ` +
`Please see the migration guide at https://sap.github.io/ui5-tooling/updates/migrate-v3/`);
}
throw new Error(`taskRepository: Unknown Task ${taskName}`);
}
try {
Expand Down
18 changes: 18 additions & 0 deletions test/lib/tasks/taskRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ test("Unknown task retrieval", (t) => {
t.deepEqual(error.message, "taskRepository: Unknown Task not-existing", "Correct exception");
});

test("Removed task retrieval", (t) => {
const error = t.throws(() => {
taskRepository.getTask("createDebugFiles");
});
t.deepEqual(error.message,
`Standard task createDebugFiles has been removed in UI5 Tooling 3.0. ` +
`Please see the migration guide at https://sap.github.io/ui5-tooling/updates/migrate-v3/`,
"Correct exception");

const error2 = t.throws(() => {
taskRepository.getTask("uglify");
});
t.deepEqual(error2.message,
`Standard task uglify has been removed in UI5 Tooling 3.0. ` +
`Please see the migration guide at https://sap.github.io/ui5-tooling/updates/migrate-v3/`,
"Correct exception");
});

test("Duplicate task", (t) => {
const myTask = {};
taskRepository.addTask("myOtherTask", myTask);
Expand Down

0 comments on commit bb0a01c

Please sign in to comment.