Move SysInfoError to BoxError

This commit is contained in:
Girish Ramakrishnan
2019-10-22 14:09:44 -07:00
parent a7614cef2e
commit 332f2e7c10
4 changed files with 12 additions and 38 deletions

View File

@@ -1,8 +1,6 @@
'use strict';
exports = module.exports = {
SysInfoError: SysInfoError,
getPublicIp: getPublicIp,
hasIPv6: hasIPv6,
@@ -15,34 +13,10 @@ var assert = require('assert'),
generic = require('./sysinfo/generic.js'),
paths = require('./paths.js'),
scaleway = require('./sysinfo/scaleway.js'),
safe = require('safetydance'),
util = require('util');
function SysInfoError(reason, errorOrMessage) {
assert.strictEqual(typeof reason, 'string');
assert(errorOrMessage instanceof Error || typeof errorOrMessage === 'string' || typeof errorOrMessage === 'undefined');
Error.call(this);
Error.captureStackTrace(this, this.constructor);
this.name = this.constructor.name;
this.reason = reason;
if (typeof errorOrMessage === 'undefined') {
this.message = reason;
} else if (typeof errorOrMessage === 'string') {
this.message = errorOrMessage;
} else {
this.message = 'Internal error';
this.nestedError = errorOrMessage;
}
}
util.inherits(SysInfoError, Error);
SysInfoError.INTERNAL_ERROR = 'Internal Error';
SysInfoError.EXTERNAL_ERROR = 'External Error';
safe = require('safetydance');
let gProvider = null;
function provider() {
if (gProvider) return gProvider;