aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
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),