0.6.1: add AppError support for optional error and data

This commit is contained in:
Dan Ballard 2023-09-22 23:11:03 -07:00
parent c9f5ec2e42
commit 9114c88110
3 changed files with 13 additions and 4 deletions

2
Cargo.lock generated
View File

@ -215,7 +215,7 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]]
name = "libcwtch"
version = "0.6.0"
version = "0.6.1"
dependencies = [
"bindgen",
"chrono",

View File

@ -1,6 +1,6 @@
[package]
name = "libcwtch"
version = "0.6.0"
version = "0.6.1"
authors = ["Dan Ballard <dan@mindstab.net>"]
edition = "2018"
license = "MIT"

View File

@ -252,7 +252,9 @@ pub enum Event {
/// Cwtch had an error at the app level (not profile level), usually in response to an API call
AppError {
/// details of the app error that occured
error: String
error: String,
/// possible data about the error
data: String
},
/// Global settings being emited from lcg, usually in response to them being sent to be saved by client
UpdateGlobalSettings {
@ -655,7 +657,14 @@ impl From<&CwtchEvent> for Event {
},
"PeerError" => Event::PeerError { error: cwtch_event.data["Error"].clone() },
"AppError" => Event::AppError {
error: cwtch_event.data["Error"].clone(),
error: match cwtch_event.data.contains_key("Error") {
true => cwtch_event.data["Error"].clone(),
false => "".to_string()
},
data: match cwtch_event.data.contains_key("Data") {
true => cwtch_event.data["Data"].clone(),
false => "".to_string()
}
},
"ContactCreated" => Event::ContactCreated {
profile_id: cwtch_event.data["ProfileOnion"].clone().into(),