Move SysInfoError to BoxError
This commit is contained in:
@@ -6,8 +6,8 @@ exports = module.exports = {
|
||||
|
||||
var assert = require('assert'),
|
||||
async = require('async'),
|
||||
superagent = require('superagent'),
|
||||
SysInfoError = require('../sysinfo.js').SysInfoError;
|
||||
BoxError = require('../boxerror.js'),
|
||||
superagent = require('superagent');
|
||||
|
||||
function getPublicIp(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
@@ -18,11 +18,11 @@ function getPublicIp(callback) {
|
||||
superagent.get('https://api.cloudron.io/api/v1/helper/public_ip').timeout(30 * 1000).end(function (error, result) {
|
||||
if (error || result.statusCode !== 200) {
|
||||
console.error('Error getting IP', error);
|
||||
return callback(new SysInfoError(SysInfoError.EXTERNAL_ERROR, 'Unable to detect IP. API server unreachable'));
|
||||
return callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Unable to detect IP. API server unreachable'));
|
||||
}
|
||||
if (!result.body && !result.body.ip) {
|
||||
console.error('Unexpected answer. No "ip" found in response body.', result.body);
|
||||
return callback(new SysInfoError(SysInfoError.EXTERNAL_ERROR, 'Unable to detect IP. No IP found in response'));
|
||||
return callback(new BoxError(BoxError.EXTERNAL_ERROR, 'Unable to detect IP. No IP found in response'));
|
||||
}
|
||||
|
||||
callback(null, result.body.ip);
|
||||
|
||||
Reference in New Issue
Block a user