10
10
import com .squareup .moshi .Moshi ;
11
11
12
12
import org .influxdb .InfluxDB ;
13
+ import org .influxdb .InfluxDBException ;
14
+ import org .influxdb .InfluxDBIOException ;
13
15
import org .influxdb .dto .BatchPoints ;
14
16
import org .influxdb .dto .Point ;
15
17
import org .influxdb .dto .Pong ;
@@ -105,7 +107,7 @@ private InetAddress parseHostAddress(final String url) {
105
107
try {
106
108
return InetAddress .getByName (httpUrl .host ());
107
109
} catch (UnknownHostException e ) {
108
- throw new RuntimeException (e );
110
+ throw new InfluxDBIOException (e );
109
111
}
110
112
}
111
113
@@ -227,7 +229,7 @@ public Pong ping() {
227
229
pong .setResponseTime (watch .elapsed (TimeUnit .MILLISECONDS ));
228
230
return pong ;
229
231
} catch (IOException e ) {
230
- throw new RuntimeException (e );
232
+ throw new InfluxDBIOException (e );
231
233
}
232
234
}
233
235
@@ -310,7 +312,7 @@ public void write(final int udpPort, final String records) {
310
312
try {
311
313
datagramSocket .send (new DatagramPacket (bytes , bytes .length , hostAddress , udpPort ));
312
314
} catch (IOException e ) {
313
- throw new RuntimeException (e );
315
+ throw new InfluxDBIOException (e );
314
316
}
315
317
}
316
318
@@ -321,7 +323,7 @@ private void initialDatagramSocket() {
321
323
try {
322
324
datagramSocket = new DatagramSocket ();
323
325
} catch (SocketException e ) {
324
- throw new RuntimeException (e );
326
+ throw new InfluxDBIOException (e );
325
327
}
326
328
}
327
329
}
@@ -360,7 +362,7 @@ public QueryResult query(final Query query) {
360
362
public void query (final Query query , final int chunkSize , final Consumer <QueryResult > consumer ) {
361
363
362
364
if (version ().startsWith ("0." ) || version ().startsWith ("1.0" )) {
363
- throw new RuntimeException ("chunking not supported" );
365
+ throw new UnsupportedOperationException ("chunking not supported" );
364
366
}
365
367
366
368
Call <ResponseBody > call = this .influxDBService .query (this .username , this .password ,
@@ -380,20 +382,20 @@ public void onResponse(final Call<ResponseBody> call, final Response<ResponseBod
380
382
}
381
383
}
382
384
try (ResponseBody errorBody = response .errorBody ()) {
383
- throw new RuntimeException (errorBody .string ());
385
+ throw new InfluxDBException (errorBody .string ());
384
386
}
385
387
} catch (EOFException e ) {
386
388
QueryResult queryResult = new QueryResult ();
387
389
queryResult .setError ("DONE" );
388
390
consumer .accept (queryResult );
389
391
} catch (IOException e ) {
390
- throw new RuntimeException (e );
392
+ throw new InfluxDBIOException (e );
391
393
}
392
394
}
393
395
394
396
@ Override
395
397
public void onFailure (final Call <ResponseBody > call , final Throwable t ) {
396
- throw new RuntimeException (t );
398
+ throw new InfluxDBException (t );
397
399
}
398
400
});
399
401
}
@@ -469,10 +471,10 @@ private <T> T execute(final Call<T> call) {
469
471
return response .body ();
470
472
}
471
473
try (ResponseBody errorBody = response .errorBody ()) {
472
- throw new RuntimeException (errorBody .string ());
474
+ throw new InfluxDBException (errorBody .string ());
473
475
}
474
476
} catch (IOException e ) {
475
- throw new RuntimeException (e );
477
+ throw new InfluxDBIOException (e );
476
478
}
477
479
}
478
480
0 commit comments