From bf5bea5fcaff71e665f3e8cd0788cef66330a766 Mon Sep 17 00:00:00 2001 From: Thomas Roch Date: Wed, 8 Nov 2017 09:06:44 +0000 Subject: [PATCH] feat: improve other error messages --- modules/Path.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Path.js b/modules/Path.js index 9d55110..a27f172 100644 --- a/modules/Path.js +++ b/modules/Path.js @@ -79,7 +79,7 @@ const tokenise = (str, tokens = []) => { // If no rules matched, throw an error (possible malformed path) if (!matched) { - throw new Error('Could not parse path.'); + throw new Error(`Could not parse path '${str}'`); } // Return tokens return tokens; @@ -140,7 +140,7 @@ export default class Path { } constructor(path) { - if (!path) throw new Error('Please supply a path'); + if (!path) throw new Error('Missing path in Path constructor'); this.path = path; this.tokens = tokenise(path); @@ -271,7 +271,7 @@ export default class Path { .filter(t => /^url-parameter/.test(t.type) && !/-splat$/.test(t.type)) .every(t => new RegExp('^' + defaultOrConstrained(t.otherVal[0]) + '$').test(encodedParams[t.val])); - if (!constraintsPassed) throw new Error('Some parameters are of invalid format'); + if (!constraintsPassed) throw new Error(`Some parameters of '${this.path}' are of invalid format`); } let base = this.tokens