File tree 2 files changed +15
-4
lines changed
openai-core/src/main/scala/io/cequence/openaiscala
openai-examples/src/main/scala/io/cequence/openaiscala/examples
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -148,15 +148,25 @@ trait RetryHelpers {
148
148
ec : ExecutionContext ,
149
149
scheduler : Scheduler
150
150
): Future [T ] = {
151
+ assert(
152
+ inputsAndMessagesToTryInOrder.nonEmpty || lastException.nonEmpty,
153
+ " At least one input or last exception must be defined!"
154
+ )
155
+
151
156
inputsAndMessagesToTryInOrder match {
152
157
case Nil =>
153
- val lastExceptionMessage = lastException.map(_.getMessage).getOrElse(" N/A" )
154
- Future .failed(
155
- new OpenAIScalaClientException (
156
- s " No more failover inputs to try! Last error: ${lastExceptionMessage}"
158
+ val lastExceptionActual = lastException.getOrElse(
159
+ throw new OpenAIScalaClientException (
160
+ s " Should never happen. No last exception provided! "
157
161
)
158
162
)
159
163
164
+ logger.error(
165
+ s " No more failover inputs to try! Throwing the last error: ${lastExceptionActual.getMessage}"
166
+ )
167
+
168
+ Future .failed(lastExceptionActual)
169
+
160
170
case _ =>
161
171
val (input, inputLogMessage) = inputsAndMessagesToTryInOrder.head
162
172
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ trait ExampleBase[T <: CloseableService] {
23
23
24
24
def main (args : Array [String ]): Unit = {
25
25
run.recover { case e : Exception =>
26
+ println(" Error received:" )
26
27
e.printStackTrace()
27
28
closeAll()
28
29
System .exit(1 )
You can’t perform that action at this time.
0 commit comments