Skip to content

Commit

Permalink
Merge pull request #111 from Esri/fix-56
Browse files Browse the repository at this point in the history
throw ArcGISAuthError instead of Error when unable to refresh a token
  • Loading branch information
patrickarlt authored Feb 1, 2018
2 parents f12822c + 8854765 commit d1a59fc
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 d1a59fc

Please sign in to comment.