File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
src/webserver/database/sqlpage_functions Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 1414- Improve error messages on invalid sqlpage function calls. The messages now contain actionable advice.
1515- Fix top navigation bar links color. They appeared "muted", with low contrast, since v0.33
1616- update to apex charts v4.5.0. This fixes a bug where tick positions in scatter plots would be incorrect.
17+ - New function: ` sqlpage.fetch_with_meta `
18+ - This function is similar to ` sqlpage.fetch ` , but it returns a json object with the following properties:
19+ - ` status ` : the http status code of the response.
20+ - ` headers ` : a json object with the response headers.
21+ - ` body ` : the response body.
22+ - ` error ` : an error message if the request failed.
23+ - This is useful when interacting with complex or unreliable external APIs.
1724
1825## 0.33.0 (2025-02-15)
1926
Original file line number Diff line number Diff line change @@ -240,7 +240,13 @@ async fn fetch_with_meta(
240240 let mut obj = encoder. serialize_map ( Some ( 3 ) ) ?;
241241 match response_result {
242242 Ok ( mut response) => {
243- obj. serialize_entry ( "status" , & response. status ( ) . as_u16 ( ) ) ?;
243+ let status = response. status ( ) ;
244+ obj. serialize_entry ( "status" , & status. as_u16 ( ) ) ?;
245+ let mut has_error = false ;
246+ if status. is_server_error ( ) {
247+ has_error = true ;
248+ obj. serialize_entry ( "error" , & format ! ( "Server error: {status}" ) ) ?;
249+ }
244250
245251 let headers = response. headers ( ) ;
246252
@@ -286,7 +292,12 @@ async fn fetch_with_meta(
286292 }
287293 Err ( e) => {
288294 log:: warn!( "Failed to read response body: {e}" ) ;
289- obj. serialize_entry ( "error" , & format ! ( "Failed to read response body: {e}" ) ) ?;
295+ if !has_error {
296+ obj. serialize_entry (
297+ "error" ,
298+ & format ! ( "Failed to read response body: {e}" ) ,
299+ ) ?;
300+ }
290301 }
291302 }
292303 }
You can’t perform that action at this time.
0 commit comments