Skip to content

Commit ce4e756

Browse files
committed
parakeet : add exception handling to parakeet_model_load [no ci]
This commit adds exception handling to the parakeet_model_load function call. The motivation for this is to avoid exceptions being thrown from this function as it is part of the extern C interface and instead log the error and return nullptr. Refs: ggml-org#3831
1 parent da55e1e commit ce4e756

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/parakeet.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3144,7 +3144,16 @@ struct parakeet_context * parakeet_init_with_params_no_state(struct parakeet_mod
31443144
parakeet_context * ctx = new parakeet_context;
31453145
ctx->params = params;
31463146

3147-
if (!parakeet_model_load(loader, *ctx)) {
3147+
bool model_loaded = false;
3148+
try {
3149+
model_loaded = parakeet_model_load(loader, *ctx);
3150+
} catch (const std::exception & e) {
3151+
PARAKEET_LOG_ERROR("%s: exception during model load: %s\n", __func__, e.what());
3152+
} catch (...) {
3153+
PARAKEET_LOG_ERROR("%s: unknown exception during model load\n", __func__);
3154+
}
3155+
3156+
if (!model_loaded) {
31483157
loader->close(loader->context);
31493158
PARAKEET_LOG_ERROR("%s: failed to load model\n", __func__);
31503159
delete ctx;

0 commit comments

Comments
 (0)