aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorGravatar Jake Swenson <jake@jakeswenson.com> 2021-08-30 08:27:10 -0700
committerGravatar Jake Swenson <jake@jakeswenson.com> 2021-08-30 08:27:10 -0700
commiteab748bf990a304063c476fb7cdeab0ec8c325f7 (patch)
tree2211af13fff6028e346641aacf3fad2a1fe3c512 /src/lib.rs
parenta78a8d9444426a608888755eb1537905b7d1d96a (diff)
downloadnotion-eab748bf990a304063c476fb7cdeab0ec8c325f7.tar.gz
notion-eab748bf990a304063c476fb7cdeab0ec8c325f7.tar.zst
notion-eab748bf990a304063c476fb7cdeab0ec8c325f7.zip
Improve ergonomics
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fab44ef..98ea97f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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),