Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
fix($location): throw Errors not Strings
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed Jun 12, 2012
1 parent d9ff5fd commit ee6014a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ng/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function convertToHashbangUrl(url, basePath, hashPrefix) {
path = match.path.substr(pathPrefix.length);

if (match.path.indexOf(pathPrefix) !== 0) {
throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !';
throw Error('Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !');
}

return composeProtocolHostPort(match.protocol, match.host, match.port) + basePath +
Expand Down Expand Up @@ -114,7 +114,7 @@ function LocationUrl(url, pathPrefix) {
var match = matchUrl(url, this);

if (match.path.indexOf(pathPrefix) !== 0) {
throw 'Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !';
throw Error('Invalid url "' + url + '", missing path prefix "' + pathPrefix + '" !');
}

this.$$path = decodeURIComponent(match.path.substr(pathPrefix.length));
Expand Down Expand Up @@ -160,8 +160,9 @@ function LocationHashbangUrl(url, hashPrefix) {
this.$$parse = function(url) {
var match = matchUrl(url, this);


if (match.hash && match.hash.indexOf(hashPrefix) !== 0) {
throw 'Invalid url "' + url + '", missing hash prefix "' + hashPrefix + '" !';
throw Error('Invalid url "' + url + '", missing hash prefix "' + hashPrefix + '" !');
}

basePath = match.path + (match.search ? '?' + match.search : '');
Expand Down

0 comments on commit ee6014a

Please sign in to comment.