Skip to content

Commit

Permalink
feat: improve other error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
troch committed Nov 8, 2017
1 parent 144d0bf commit bf5bea5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bf5bea5

Please sign in to comment.