UNPKG

nhentai-tools

Version:

A toolset to interact with the doujin site nhentai.net

25 lines (24 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DoesNotExistError = exports.createError = void 0; const createError = (error) => { if (!error.isAxiosError) { throw new Error(`nhentai-tools: "${error}"`); } else { const message = error.response.data.error; switch (message) { case 'does not exist': throw new DoesNotExistError(message, error.config); } throw new Error(`unknown error: "${message}"`); } }; exports.createError = createError; class DoesNotExistError extends Error { constructor(message, config) { var _a; super(`nhentai-api: returned "${message}" from query ${(_a = config.method) === null || _a === void 0 ? void 0 : _a.toUpperCase()}: ${config.url}${config.params ? ` with params ${JSON.stringify(config.params, null, 2)}` : ' with no params'}.`); this.name = 'DoesNotExistError'; } } exports.DoesNotExistError = DoesNotExistError;