Skip to content

Commit

Permalink
fix(UserSession): throw ArcGISAuthError instead of Error when unable …
Browse files Browse the repository at this point in the history
…to refresh a token

AFFECTS PACKAGES:
@esri/arcgis-rest-auth

ISSUES CLOSED: #56
  • Loading branch information
patrickarlt committed Feb 1, 2018
1 parent f12822c commit 8854765
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/arcgis-rest-auth/src/UserSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ export class UserSession implements IAuthenticationManager {
return this.refreshWithRefreshToken();
}

return Promise.reject(new Error("Unable to refresh token."));
return Promise.reject(new ArcGISAuthError("Unable to refresh token."));
}

/**
Expand Down
8 changes: 7 additions & 1 deletion packages/arcgis-rest-auth/test/UserSession.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { UserSession, IFetchTokenResponse } from "../src/index";
import { ArcGISRequestError, ErrorTypes } from "@esri/arcgis-rest-request";
import {
ArcGISRequestError,
ArcGISAuthError,
ErrorTypes
} from "@esri/arcgis-rest-request";
import * as fetchMock from "fetch-mock";
import { YESTERDAY, TOMORROW } from "./utils";

Expand Down Expand Up @@ -350,6 +354,8 @@ describe("UserSession", () => {
});

session.refreshSession().catch(e => {
expect(e instanceof ArcGISAuthError).toBeTruthy();
expect(e.name).toBe("ArcGISAuthError");
expect(e.message).toBe("Unable to refresh token.");
done();
});
Expand Down

0 comments on commit 8854765

Please sign in to comment.