@@ -131,8 +131,23 @@ static void container_thread_entry(void *args) {
131131 // Set TLS for the container's WASM module
132132 current_module_tls = & module_inst ;
133133#endif
134- // Run the WASM main function
135- bool success = wasm_application_execute_main (module_inst , 0 , NULL );
134+
135+ // Run the WASM main function with exception handling
136+ bool success = false;
137+ const char * exception = NULL ;
138+
139+ // Clear any previous exceptions
140+ wasm_runtime_clear_exception (module_inst );
141+
142+ // Execute main function
143+ success = wasm_application_execute_main (module_inst , 0 , NULL );
144+
145+ // Check for exceptions
146+ exception = wasm_runtime_get_exception (module_inst );
147+ if (exception ) {
148+ LOG_ERR ("Container %d exception: %s" , container -> container_ID , exception );
149+ success = false;
150+ }
136151 // Update container status
137152 if (container -> container_runtime_status != CONTAINER_STATUS_STOPPED )
138153 container -> container_runtime_status = success ? CONTAINER_STATUS_STOPPED : CONTAINER_STATUS_ERROR ;
@@ -161,7 +176,12 @@ static void container_thread_entry(void *args) {
161176 }
162177 core_mutex_unlock (& container -> lock );
163178
164- LOG_INF ("Container thread %d exited cleanly" , container -> container_ID );
179+ if (success ) {
180+ LOG_INF ("Container %d completed successfully" , container -> container_ID );
181+ } else {
182+ LOG_ERR ("Container %d failed: %s" , container -> container_ID ,
183+ exception ? exception : "unknown error" );
184+ }
165185
166186 // Clean up WASM runtime thread environment
167187 wasm_runtime_destroy_thread_env ();
0 commit comments