Skip to content

Commit 6b270ac

Browse files
committed
feat(log): debug output
1 parent 43147da commit 6b270ac

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
!example.ron
1717
test/*
1818
.vscode
19+
20+
static

src/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ impl ErrorExtensions for QueryError {
1515
fn extend(&self) -> FieldError {
1616
self.extend_with(|err, e| match err {
1717
QueryError::NotFoundError(resource) => e.set("code", format!("{} not found", resource)),
18-
QueryError::ServerError(reason) => e.set("reason", reason.to_string())
18+
QueryError::ServerError(reason) => e.set("reason", reason.to_string()),
1919
})
2020
}
2121
}

src/model.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use crate::errors::QueryError;
22
use async_graphql::{Context, ErrorExtensions, FieldResult, Object, SimpleObject};
3+
use dashmap::DashMap;
4+
use log::debug;
35
use serde::{Deserialize, Serialize};
46
use std::path::PathBuf;
57
use tokio::fs::File;
68
use tokio::io::AsyncReadExt;
7-
use dashmap::DashMap;
89

910
pub struct Query;
10-
pub type Storage = DashMap::<String, String>;
11+
pub type Storage = DashMap<String, String>;
1112

1213
#[Object]
1314
impl Query {
@@ -62,7 +63,10 @@ impl Query {
6263
None => {
6364
File::open(&resource.resource)
6465
.await
65-
.map_err(|_| QueryError::ServerError("internal error".to_string()).extend())?
66+
.map_err(|err| {
67+
debug!("{}", &format!("{:?}", err));
68+
QueryError::ServerError("open internal error".to_string()).extend()
69+
})?
6670
.read_to_string(&mut result.content)
6771
.await
6872
.map_err(|_| QueryError::ServerError("internal error".to_string()).extend())?;

test/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)