Skip to content

Commit 132ec1b

Browse files
committed
fix(#160) : changed AuthHttpError to Error
1 parent a3d2093 commit 132ec1b

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

angular2-jwt.spec.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "core-js";
2-
import {AuthConfig, AuthHttp, tokenNotExpired, JwtHelper} from "./angular2-jwt";
2+
import {AuthConfig, AuthHttp, tokenNotExpired, JwtHelper, AuthHttpError} from "./angular2-jwt";
33
import {Observable} from "rxjs";
44
import {Base64} from "js-base64";
55

@@ -173,4 +173,26 @@ describe("AuthHttp", () => {
173173
});
174174
});
175175
});
176-
});
176+
});
177+
178+
describe("AuthHttpError", () => {
179+
180+
'use strict';
181+
182+
it("constructor fails to set the error message", () => {
183+
const message = 'This is an error';
184+
let error = new AuthHttpError(message);
185+
expect(error.message).toBe('');
186+
});
187+
});
188+
189+
describe("Error", () => {
190+
191+
'use strict';
192+
193+
it("constructor should set the error message", () => {
194+
const message = 'This is an error';
195+
let error = new Error(message);
196+
expect(error.message).toBe(message);
197+
});
198+
});

angular2-jwt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class AuthHttp {
103103
if (!tokenNotExpired(undefined, token)) {
104104
if (!this.config.noJwtError) {
105105
return new Observable<Response>((obs: any) => {
106-
obs.error(new AuthHttpError('No JWT present or has expired'));
106+
obs.error(new Error('No JWT present or has expired'));
107107
});
108108
}
109109
} else {

0 commit comments

Comments
 (0)