Fix incorrect promise syntax.
Always reject promises with an Error. This should fix the following, after sending an annotation to graphite/influxdb fails: Warning: a promise was rejected with a non-error: [object Undefined]
This commit is contained in:
parent
34b3d67fb9
commit
2e4346bf8d
|
|
@ -48,11 +48,11 @@ module.exports = {
|
|||
const lib = options.graphite.httpPort === 443 ? https : http;
|
||||
const req = lib.request(postOptions, res => {
|
||||
if (res.statusCode !== 200) {
|
||||
log.error(
|
||||
'Got %s from Graphite when sending annotation',
|
||||
res.statusCode
|
||||
const e = new Error(
|
||||
`Got ${res.statusCode} from Graphite when sending annotation`
|
||||
);
|
||||
reject();
|
||||
log.warn(e.message);
|
||||
reject(e);
|
||||
} else {
|
||||
res.setEncoding('utf8');
|
||||
log.info('Sent annotation to Graphite');
|
||||
|
|
|
|||
|
|
@ -56,12 +56,11 @@ module.exports = {
|
|||
const lib = options.influxdb.protocol === 'https' ? https : http;
|
||||
const req = lib.request(postOptions, res => {
|
||||
if (res.statusCode !== 204) {
|
||||
log.error(
|
||||
'Got %s from InfluxDB when sending annotation %s',
|
||||
res.statusCode,
|
||||
res.statusMessage
|
||||
const e = new Error(
|
||||
`Got ${res.statusCode} from InfluxDB when sending annotation ${res.statusMessage}`
|
||||
);
|
||||
reject();
|
||||
log.warn(e.message);
|
||||
reject(e);
|
||||
} else {
|
||||
res.setEncoding('utf-8');
|
||||
log.info('Sent annotation to InfluxDB');
|
||||
|
|
|
|||
Loading…
Reference in New Issue