API V3: Implement Structured Error Handling and Validation Tests

- Updated api_get_object and api_post_object to extract rich metadata (meta.details) from 400/500 responses.
- Enables frontend to bubble up specific DB schema, validation, and constraint errors for better debugging.
- Added 'V3 Hardening' section to /testing dashboard with automated tests for Permissive Mode and Structured Error extraction.
This commit is contained in:
Scott Idem
2026-01-19 17:38:05 -05:00
parent 8566917be1
commit c40a296a77
3 changed files with 96 additions and 8 deletions

View File

@@ -184,7 +184,21 @@ export const get_object = async function get_object({
return false;
}
console.log('The response was not ok. Throwing an error!');
// Structured Error Handling (V3): Attempt to get rich error metadata
let error_json: any = null;
try {
error_json = await response.json();
} catch (e) {
// Not JSON
}
if (log_lvl) console.log('The response was not ok. Structured Error Check:', error_json);
if (error_json?.meta?.details) {
// Return the rich error object so caller can handle specific categories (database_schema, etc)
return error_json;
}
throw new Error(`HTTP error! status: ${response.status}`);
}