Skip to content

Commit

Permalink
Use @xboxreplay/errors package
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis-Bize committed Aug 14, 2019
1 parent 2aee11c commit bb13507
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/error.ts → src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { XboxReplayError } from '@xboxreplay/error';
import { XboxReplayError } from '@xboxreplay/errors';
import * as HTTPStatusCodes from './http-status-codes';

const errors = {
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
)
Expand All @@ -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;
};

Expand All @@ -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;
Expand Down

0 comments on commit bb13507

Please sign in to comment.