Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.runanywhere.sdk.public.RunAnywhere
import com.runanywhere.sdk.public.types.RAModelInfo
import com.runanywhere.sdk.public.types.RAModelLoadRequest
import com.runanywhere.sdk.public.types.RAModelLoadResult
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

Expand All @@ -48,7 +49,9 @@ suspend fun RunAnywhere.loadModel(request: RAModelLoadRequest): RAModelLoadResul
}
try {
ensureServicesReady()
} catch (_: Throwable) {
} catch (e: CancellationException) {
throw e
} catch (_: Exception) {
}
val result =
CppBridgeModelLifecycle.load(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import com.runanywhere.sdk.infrastructure.logging.SDKLogger
import com.runanywhere.sdk.public.RunAnywhere
import com.runanywhere.sdk.public.types.RASTTOptions
import com.runanywhere.sdk.public.types.RASTTOutput
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
Expand Down Expand Up @@ -108,7 +109,9 @@ fun RunAnywhere.transcribeStream(
trySend(RASTTPartialResult(is_final = true))
}
close()
} catch (e: Throwable) {
} catch (e: CancellationException) {
throw e
} catch (e: Exception) {
trySend(
RASTTPartialResult(
text = "STT stream failed: ${e.message ?: e::class.simpleName.orEmpty()}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ suspend fun RunAnywhere.downloadModel(
downloadLogger.info(
"Download cancelled for ${resolvedModel.id} (task=${startResult.task_id})",
)
} catch (e: Throwable) {
} catch (e: Exception) {
downloadLogger.warn(
"Failed to cancel native download for ${resolvedModel.id} " +
"(task=${startResult.task_id}): ${e.message}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.runanywhere.sdk.native.bridge.RunAnywhereBridge
import com.runanywhere.sdk.public.RunAnywhere
import com.runanywhere.sdk.public.types.RATTSOptions
import com.runanywhere.sdk.public.types.RATTSOutput
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.NonCancellable
Expand Down Expand Up @@ -127,7 +128,9 @@ fun RunAnywhere.synthesizeStream(
trySend(output).isSuccess
}
}
} catch (t: Throwable) {
} catch (t: CancellationException) {
throw t
} catch (t: Exception) {
ttsLogger.warn("synthesizeStream errored: ${t.message}")
} finally {
close()
Expand Down
Loading