Skip to content

Commit d0f795e

Browse files
committed
feat: Use custom errors
1 parent 371fb1f commit d0f795e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/zabbix.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var request = require('request');
2+
var ZabbixError = require('./ZabbixError');
23

34
var Client = function (url, user, password) {
45
this.url = url;
@@ -38,15 +39,15 @@ Client.prototype.call = function call(method, params, callback) {
3839
result = JSON.parse(body);
3940
callback(null, response, result);
4041
} else if (response.statusCode == 412) {
41-
callback(new Error('Invalid parameters.'), response, body);
42+
callback(new ZabbixError('Invalid parameters.'), response, body);
4243
} else {
4344
// 1.9.6 just returns a empty response with Content-Length 0 if the method does not exist.
4445
// 2.x returns a proper response!
4546
if (this.apiversion == '1.2') {
46-
callback(new Error('That method does most likely not exist.'), response, 'Method missing!');
47+
callback(new ZabbixError('That method does most likely not exist.'), response, 'Method missing!');
4748
} else {
4849
// If we get here something else is broken, we should look into this more and handle more special cases (in a general way).
49-
callback(new Error('Something else went wrong'), response, body);
50+
callback(new ZabbixError('Something else went wrong'), response, body);
5051
}
5152

5253
}

0 commit comments

Comments
 (0)