@@ -427,17 +427,35 @@ int test_offline_error(const char *db_path) {
427427 goto abort_test ;
428428 }
429429
430- // Verify the error message contains the expected text
431- const char * expected_error = "cloudsync_network_send_changes unable to upload BLOB changes to remote host" ;
432- if (!errmsg || strstr (errmsg , expected_error ) == NULL ) {
433- printf ("Error: Expected error message containing '%s', but got '%s'\n" ,
434- expected_error , errmsg ? errmsg : "NULL" );
435- if (errmsg ) sqlite3_free (errmsg );
430+ // Verify the error JSON contains expected fields using SQLite JSON extraction
431+ if (!errmsg ) {
432+ printf ("Error: Expected an error message, but got NULL\n" );
436433 rc = SQLITE_ERROR ;
437434 goto abort_test ;
438435 }
439436
440- if (errmsg ) sqlite3_free (errmsg );
437+ char verify_sql [1024 ];
438+ snprintf (verify_sql , sizeof (verify_sql ),
439+ "SELECT json_extract('%s', '$.errors[0].status');" , errmsg );
440+ rc = db_expect_str (db , verify_sql , "500" );
441+ if (rc != SQLITE_OK ) { printf ("Offline error: unexpected status in: %s\n" , errmsg ); sqlite3_free (errmsg ); goto abort_test ; }
442+
443+ snprintf (verify_sql , sizeof (verify_sql ),
444+ "SELECT json_extract('%s', '$.errors[0].code');" , errmsg );
445+ rc = db_expect_str (db , verify_sql , "internal_server_error" );
446+ if (rc != SQLITE_OK ) { printf ("Offline error: unexpected code in: %s\n" , errmsg ); sqlite3_free (errmsg ); goto abort_test ; }
447+
448+ snprintf (verify_sql , sizeof (verify_sql ),
449+ "SELECT json_extract('%s', '$.errors[0].title');" , errmsg );
450+ rc = db_expect_str (db , verify_sql , "Internal Server Error" );
451+ if (rc != SQLITE_OK ) { printf ("Offline error: unexpected title in: %s\n" , errmsg ); sqlite3_free (errmsg ); goto abort_test ; }
452+
453+ snprintf (verify_sql , sizeof (verify_sql ),
454+ "SELECT json_extract('%s', '$.errors[0].detail');" , errmsg );
455+ rc = db_expect_str (db , verify_sql , "failed to resolve token data: failed to resolve db user for api key: db: connect sqlitecloud failed after 3 attempts: Your free node has been paused due to inactivity. To resume usage, please restart your node from your dashboard: https://dashboard.sqlitecloud.io" );
456+ if (rc != SQLITE_OK ) { printf ("Offline error: unexpected detail in: %s\n" , errmsg ); sqlite3_free (errmsg ); goto abort_test ; }
457+
458+ sqlite3_free (errmsg );
441459 rc = SQLITE_OK ;
442460
443461ABORT_TEST
0 commit comments