From 20af8cd17ea50397ff33916eb21e68b480070a90 Mon Sep 17 00:00:00 2001 From: bitful-pannul Date: Wed, 11 Sep 2024 00:20:09 +0300 Subject: [PATCH] app_store: handling error responses --- kinode/packages/app_store/api/app_store:sys-v1.wit | 2 +- kinode/packages/app_store/app_store/src/lib.rs | 7 ++++++- kinode/packages/app_store/downloads/src/lib.rs | 9 ++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/kinode/packages/app_store/api/app_store:sys-v1.wit b/kinode/packages/app_store/api/app_store:sys-v1.wit index b7b3c2db..2e69b8be 100644 --- a/kinode/packages/app_store/api/app_store:sys-v1.wit +++ b/kinode/packages/app_store/api/app_store:sys-v1.wit @@ -55,6 +55,7 @@ interface downloads { http-client-error, blob-not-found, vfs-error, + handling-error(string), } record download-complete-request { @@ -192,7 +193,6 @@ interface main { local(local-response), chain-error(chain-error), download-error(download-error), - send-error(string), handling-error(string), } diff --git a/kinode/packages/app_store/app_store/src/lib.rs b/kinode/packages/app_store/app_store/src/lib.rs index e462d3e8..b8c1a88d 100644 --- a/kinode/packages/app_store/app_store/src/lib.rs +++ b/kinode/packages/app_store/app_store/src/lib.rs @@ -78,7 +78,12 @@ fn init(our: Address) { } Ok(message) => { if let Err(e) = handle_message(&our, &mut state, &mut http_server, &message) { - print_to_terminal(1, &format!("main: error handling message: {e:?}")); + let error_message = format!("error handling message: {e:?}"); + print_to_terminal(1, &error_message); + Response::new() + .body(AppStoreResponse::HandlingError(error_message)) + .send() + .unwrap(); } } } diff --git a/kinode/packages/app_store/downloads/src/lib.rs b/kinode/packages/app_store/downloads/src/lib.rs index 8f1a993e..a20bba02 100644 --- a/kinode/packages/app_store/downloads/src/lib.rs +++ b/kinode/packages/app_store/downloads/src/lib.rs @@ -94,7 +94,14 @@ fn init(our: Address) { &mut tmp, &mut auto_updates, ) { - print_to_terminal(1, &format!("downloads: error handling message: {:?}", e)); + let error_message = format!("error handling message: {e:?}"); + print_to_terminal(1, &error_message); + Response::new() + .body(DownloadResponses::Err(DownloadError::HandlingError( + error_message, + ))) + .send() + .unwrap(); } } }