From bb135074971cf659c6da786d5e9f7a959126e8ea Mon Sep 17 00:00:00 2001 From: Alexis-Bize Date: Wed, 14 Aug 2019 14:42:16 +0200 Subject: [PATCH] Use @xboxreplay/errors package --- package-lock.json | 6 +++--- package.json | 2 +- src/{error.ts => errors.ts} | 2 +- src/index.ts | 14 +++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) rename src/{error.ts => errors.ts} (95%) diff --git a/package-lock.json b/package-lock.json index 35c1794..6c10802 100644 --- a/package-lock.json +++ b/package-lock.json @@ -515,10 +515,10 @@ "integrity": "sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw==", "dev": true }, - "@xboxreplay/error": { + "@xboxreplay/errors": { "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@xboxreplay/error/-/error-0.1.0.tgz", - "integrity": "sha512-mcL7fArUmNJJAD4FZ+DPQomg0hlhr35H36DBD+iz4tm1+hw4jtN2cA48MEi+Jx/Zr8bKTrreGLVKh5fEoi2afQ==" + "resolved": "https://registry.npmjs.org/@xboxreplay/errors/-/errors-0.1.0.tgz", + "integrity": "sha512-Tgz1d/OIPDWPeyOvuL5+aai5VCcqObhPnlI3skQuf80GVF3k1I0lPCnGC+8Cm5PV9aLBT5m8qPcJoIUQ2U4y9g==" }, "abab": { "version": "2.0.0", diff --git a/package.json b/package.json index 01c02fd..ac6ffb8 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test": "./node_modules/.bin/jest --runInBand" }, "dependencies": { - "@xboxreplay/error": "^0.1.0", + "@xboxreplay/errors": "^0.1.0", "request": "^2.88.0" }, "peerDependencies": { diff --git a/src/error.ts b/src/errors.ts similarity index 95% rename from src/error.ts rename to src/errors.ts index b56c2f2..72cc385 100644 --- a/src/error.ts +++ b/src/errors.ts @@ -1,4 +1,4 @@ -import { XboxReplayError } from '@xboxreplay/error'; +import { XboxReplayError } from '@xboxreplay/errors'; import * as HTTPStatusCodes from './http-status-codes'; const errors = { diff --git a/src/index.ts b/src/index.ts index 4fb17c9..c0b1c5e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import * as request from 'request'; import * as HTTPStatusCodes from './http-status-codes'; -import * as XboxLiveAPIError from './error'; +import * as errors from './errors'; import { join } from 'path'; import { @@ -80,18 +80,18 @@ export const call = ( method }, (err: any, response: request.Response, body: any) => { - if (err) return reject(XboxLiveAPIError.internal(err.message)); + if (err) return reject(errors.internal(err.message)); const statusCode = response.statusCode; if (statusCode === HTTPStatusCodes.FORBIDDEN) { - return reject(XboxLiveAPIError.forbidden()); + return reject(errors.forbidden()); } else if (statusCode === HTTPStatusCodes.UNAUTHORIZED) { - return reject(XboxLiveAPIError.unauthorized()); + return reject(errors.unauthorized()); } if (_isCallStatusCodeValid(response.statusCode) === false) return reject( - XboxLiveAPIError.requestError( + errors.requestError( `Got a request error for "${uri}"`, response.statusCode ) @@ -117,7 +117,7 @@ export const getPlayerXUID = async ( ); if (response.profileUsers[0] === void 0) { - throw XboxLiveAPIError.internal(); + throw errors.internal(); } else return response.profileUsers[0].id; }; @@ -134,7 +134,7 @@ export const getPlayerSettings = async ( ); if (response.profileUsers[0] === void 0) { - throw XboxLiveAPIError.internal(); + throw errors.internal(); } return response.profileUsers[0].settings;