File tree Expand file tree Collapse file tree
src/main/java/com/imsweb/seerapi/client Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44package com .imsweb .seerapi .client ;
55
66import java .io .IOException ;
7- import java .util .Objects ;
87
98import org .jetbrains .annotations .NotNull ;
109
1110import com .fasterxml .jackson .databind .ObjectMapper ;
1211
1312import okhttp3 .Interceptor ;
1413import okhttp3 .Response ;
14+ import okhttp3 .ResponseBody ;
1515
1616/**
1717 * Interceptor to catch all non-200 responses and convert them to exceptions.
@@ -24,11 +24,13 @@ public Response intercept(Chain chain) throws IOException {
2424 Response response = chain .proceed (chain .request ());
2525
2626 if (response .code () != 200 ) {
27- // convert body to error response
2827 ErrorResponse error = null ;
29- if (response .body () != null ) {
28+
29+ // convert body to error response
30+ ResponseBody body = response .body ();
31+ if (body != null ) {
3032 try {
31- error = new ObjectMapper ().readValue (Objects . requireNonNull ( response . body ()) .byteStream (), ErrorResponse .class );
33+ error = new ObjectMapper ().readValue (body .byteStream (), ErrorResponse .class );
3234 }
3335 catch (IOException e ) {
3436 // sometimes the error message is not right format (like for 404 errors)
You can’t perform that action at this time.
0 commit comments