@zougui/furaffinity
Version:
78 lines • 2.95 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkErrors = void 0;
const FurAffinityError_1 = require("../../FurAffinityError");
const checkErrors = (res, url) => {
if (res.statusCode !== 200) {
throw new FurAffinityError_1.FurAffinityError({
message: 'An error occured while fetching furaffinity\'s web page.',
code: res.statusCode,
url,
});
}
if (res.body.includes('You are allowed to views the statistics of your own account alone.')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'You are allowed to views the statistics of your own account alone.',
code: 401,
url,
});
}
if (res.body.includes('you must log in')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'You must log in.',
code: 403,
url,
});
}
if (res.body.includes('This user has voluntarily disabled access to their userpage.')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'This user has voluntarily disabled access to their userpage.',
code: 403,
url,
});
}
if (res.body.includes('The submission you are trying to find is not in our database.')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'The submission you are trying to find is not in furaffinity\'s database.',
code: 404,
url,
});
}
if (res.body.includes('The journal you are trying to find is not in our database.')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'The journal you are trying to find is not in furaffinity\'s database.',
code: 404,
url,
});
}
if (res.body.includes('This user cannot be found.')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'This user cannot be found.',
code: 404,
url,
});
}
if (res.body.includes('was not found in our database')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'Data not found in furaffinity\'s database',
code: 404,
url,
});
}
if (res.body.includes('For more information please check the')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'Furaffinity internal server error',
code: 500,
url,
});
}
if (res.body.includes('The server is currently having difficulty responding to all requests.')) {
throw new FurAffinityError_1.FurAffinityError({
message: 'Furaffinity\'s server is currently having difficulty responding to all requests.',
code: 503,
url,
});
}
};
exports.checkErrors = checkErrors;
//# sourceMappingURL=checkErrors.js.map