This repository was archived by the owner on Feb 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-12
lines changed
src/main/java/dev/ai4j/openai4j Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change 1+ package dev .ai4j .openai4j ;
2+
3+ public class OpenAiHttpException extends RuntimeException {
4+
5+ private final int code ;
6+
7+ public OpenAiHttpException (int code , String message ) {
8+ super (message );
9+ this .code = code ;
10+ }
11+
12+ public int code () {
13+ return code ;
14+ }
15+ }
Original file line number Diff line number Diff line change 55class Utils {
66
77 static RuntimeException toException (retrofit2 .Response <?> response ) throws IOException {
8-
9- int code = response .code ();
10- String body = response .errorBody ().string ();
11-
12- String errorMessage = String .format ("status code: %s; body: %s" , code , body );
13- return new RuntimeException (errorMessage );
8+ return new OpenAiHttpException (response .code (), response .errorBody ().string ());
149 }
1510
1611 static RuntimeException toException (okhttp3 .Response response ) throws IOException {
17-
18- int code = response .code ();
19- String body = response .body ().string ();
20-
21- String errorMessage = String .format ("status code: %s; body: %s" , code , body );
22- return new RuntimeException (errorMessage );
12+ return new OpenAiHttpException (response .code (), response .body ().string ());
2313 }
2414}
You can’t perform that action at this time.
0 commit comments