UNPKG

devopness-sdk-js

Version:

Devopness API JS/TS SDK - Painless essential DevOps to everyone

30 lines (29 loc) 1.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ApiError = exports.ArgumentNullException = void 0; class ArgumentNullException extends Error { constructor(param, method, msg) { // TO DO: check if it's possible to use reflection/prototype to retrieve the method name super(msg || `Value cannot be null. Missing required parameter: "${param}" when calling "${method}"`); this.param = param; } } exports.ArgumentNullException = ArgumentNullException; class ApiError extends Error { constructor(error) { if (!error.response) { throw error; } super('Devopness API response error'); this.status = error.response.status; if (error.response.data) { if (error.response.data.message) { this.message = error.response.data.message; } if (error.response.data.errors) { this.errors = error.response.data.errors; } } } } exports.ApiError = ApiError;