From 562f3d7696b7c20252e6063bf44647bd52cec811 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Fri, 14 Feb 2020 13:44:40 +0100 Subject: [PATCH] fix(schedule): use consistent error messages --- lib/workers/branch/schedule.ts | 8 ++++---- test/config/__snapshots__/validation.spec.ts.snap | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/workers/branch/schedule.ts b/lib/workers/branch/schedule.ts index c3ff3f3636..c46d3b794f 100644 --- a/lib/workers/branch/schedule.ts +++ b/lib/workers/branch/schedule.ts @@ -16,7 +16,7 @@ export function hasValidTimezone( timezone: string ): [boolean] | [boolean, string] { if (!moment.tz.zone(timezone)) { - return [false, `Invalid timezone: ${timezone}`]; + return [false, `Invalid schedule: Unsupported timezone ${timezone}`]; } return [true]; } @@ -39,12 +39,12 @@ export function hasValidSchedule( ); const parsedSchedule = later.parse.text(massagedText); if (parsedSchedule.error !== -1) { - message = `Failed to parse schedule "${scheduleText}"`; + message = `Invalid schedule: Failed to parse "${scheduleText}"`; // It failed to parse return true; } if (parsedSchedule.schedules.some(s => s.m)) { - message = `Schedule "${scheduleText}" should not specify minutes`; + message = `Invalid schedule: "${scheduleText}" should not specify minutes`; return true; } if ( @@ -52,7 +52,7 @@ export function hasValidSchedule( s => s.M || s.d !== undefined || s.D || s.t_a !== undefined || s.t_b ) ) { - message = `Schedule "${scheduleText}" has no months, days of week or time of day`; + message = `Invalid schedule: "${scheduleText}" has no months, days of week or time of day`; return true; } // It must be OK diff --git a/test/config/__snapshots__/validation.spec.ts.snap b/test/config/__snapshots__/validation.spec.ts.snap index 05e4eb1e59..1cefb6bf69 100644 --- a/test/config/__snapshots__/validation.spec.ts.snap +++ b/test/config/__snapshots__/validation.spec.ts.snap @@ -41,11 +41,11 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "Invalid schedule: \`Schedule \\"every 15 mins every weekday\\" should not specify minutes\`", + "message": "Invalid schedule: \`Invalid schedule: \\"every 15 mins every weekday\\" should not specify minutes\`", }, Object { "depName": "Configuration Error", - "message": "extends: Invalid timezone: Europe/Brussel", + "message": "extends: Invalid schedule: Unsupported timezone Europe/Brussel", }, Object { "depName": "Configuration Error", @@ -57,7 +57,7 @@ Array [ }, Object { "depName": "Configuration Error", - "message": "timezone: Invalid timezone: Asia", + "message": "timezone: Invalid schedule: Unsupported timezone Asia", }, ] `; -- GitLab