Skip to content

Commit 25b2a91

Browse files
committed
Merge pull request #65 from pixelhandler/add-error-name
Add error names to utils/errors
2 parents 482c67a + 08ad8ef commit 25b2a91

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

addon/utils/errors.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function ServerError(message = 'Server Error', response = null) {
1414
_error.name = this.name = 'ServerError';
1515
this.stack = _error.stack;
1616
this.message = _error.message;
17-
17+
this.name = 'ServerError';
1818
this.response = response;
1919
this.errors = (response) ? response.errors || null : null;
2020
}
@@ -31,7 +31,7 @@ export function ClientError(message = 'Client Error', response = null) {
3131
_error.name = this.name = 'ClientError';
3232
this.stack = _error.stack;
3333
this.message = _error.message;
34-
34+
this.name = 'ClientError';
3535
this.response = response;
3636
this.errors = (response) ? response.errors || null : null;
3737
}
@@ -49,7 +49,7 @@ export function FetchError(message = 'Fetch Error', error = null, response = nul
4949
_error.name = this.name = 'FetchError';
5050
this.stack = (error && error.stack) ? error.stack : _error.stack;
5151
this.message = (error && error.message) ? error.message : _error.message;
52-
52+
this.name = 'FetchError';
5353
this.response = response;
5454
this.error = error || _error;
5555
}

tests/unit/utils/errors-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ test('ServerError', function(assert) {
88
function() {
99
throw new ServerError();
1010
},
11-
ServerError,
12-
"raised error is an instance of ServerError"
11+
Error,
12+
"raised ServerError is an instance of Error"
1313
);
1414
});
1515

@@ -18,8 +18,8 @@ test('ClientError', function(assert) {
1818
function() {
1919
throw new ClientError();
2020
},
21-
ClientError,
22-
"raised error is an instance of ClientError"
21+
Error,
22+
"raised ClientError is an instance of Error"
2323
);
2424
});
2525

@@ -28,7 +28,7 @@ test('FetchError', function(assert) {
2828
function() {
2929
throw new FetchError();
3030
},
31-
FetchError,
32-
"raised error is an instance of FetchError"
31+
Error,
32+
"raised FetchError is an instance of Error"
3333
);
3434
});

0 commit comments

Comments
 (0)