|
1 | 1 | var request = require('request'); |
| 2 | +var ZabbixError = require('./ZabbixError'); |
2 | 3 |
|
3 | 4 | var Client = function (url, user, password) { |
4 | 5 | this.url = url; |
@@ -38,15 +39,15 @@ Client.prototype.call = function call(method, params, callback) { |
38 | 39 | result = JSON.parse(body); |
39 | 40 | callback(null, response, result); |
40 | 41 | } else if (response.statusCode == 412) { |
41 | | - callback(new Error('Invalid parameters.'), response, body); |
| 42 | + callback(new ZabbixError('Invalid parameters.'), response, body); |
42 | 43 | } else { |
43 | 44 | // 1.9.6 just returns a empty response with Content-Length 0 if the method does not exist. |
44 | 45 | // 2.x returns a proper response! |
45 | 46 | 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!'); |
47 | 48 | } else { |
48 | 49 | // 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); |
50 | 51 | } |
51 | 52 |
|
52 | 53 | } |
|
0 commit comments