Add warning message for erroneous responses to make debugging easier
MODIFY
lib/jsonwp-proxy/proxy.js
lib/jsonwp-proxy/proxy.js
@@ -141,8 +141,17 @@ class JWProxy {
}
}
} catch (e) {
+ let responseError;
+ try {
+ responseError = JSON.parse(e.error);
+ } catch (e1) {
+ if (_.isString(e.error) && e.error.length) {
+ log.warn(`Got unexpected response: ${_.truncate(e.error, {length: 300})}`);
+ }
+ responseError = _.isPlainObject(e.error) ? e.error : null;
+ }
throw new errors.ProxyRequestError(`Could not proxy command to remote server. ` +
- `Original error: ${e.message}`, e.error);
+ `Original error: ${e.message}`, responseError);
}
return [res, resBody];
}

Add warning message for erroneous responses to make debugging easier (#119)