diff options
author | 2021-08-30 08:27:10 -0700 | |
---|---|---|
committer | 2021-08-30 08:27:10 -0700 | |
commit | eab748bf990a304063c476fb7cdeab0ec8c325f7 (patch) | |
tree | 2211af13fff6028e346641aacf3fad2a1fe3c512 /src/lib.rs | |
parent | a78a8d9444426a608888755eb1537905b7d1d96a (diff) | |
download | notion-eab748bf990a304063c476fb7cdeab0ec8c325f7.tar.gz notion-eab748bf990a304063c476fb7cdeab0ec8c325f7.tar.zst notion-eab748bf990a304063c476fb7cdeab0ec8c325f7.zip |
Improve ergonomics
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -5,6 +5,7 @@ use crate::models::{Block, Database, ListResponse, Object, Page}; use ids::AsIdentifier; use reqwest::header::{HeaderMap, HeaderValue}; use reqwest::{header, Client, ClientBuilder, RequestBuilder}; +use tracing::Instrument; pub mod ids; pub mod models; @@ -86,9 +87,11 @@ impl NotionApi { let json = self .client .execute(request) + .instrument(tracing::trace_span!("Sending request")) .await .map_err(|source| Error::RequestFailed { source })? .text() + .instrument(tracing::trace_span!("Reading response")) .await .map_err(|source| Error::ResponseIoError { source })?; @@ -100,6 +103,7 @@ impl NotionApi { } let result = serde_json::from_str(&json).map_err(|source| Error::JsonParseError { source })?; + match result { Object::Error { error } => Err(Error::ApiError { error }), response => Ok(response), |