-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: some error handling and improvements #25
base: main
Are you sure you want to change the base?
Conversation
gabyx
commented
Oct 3, 2024
•
edited
Loading
edited
- Some error handling and some obsolete stuff.
95f816c
to
e2e6181
Compare
collections: HashMap<String, Vec<String>>, | ||
} | ||
|
||
// Shared app state built from config and used by services | ||
#[derive(Clone, Debug)] | ||
struct AppState { | ||
// TODO: Add doc what these dict maps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: Add doc what these dict maps. | |
// collection name -> associated term matcher |
struct Config { | ||
host: String, | ||
port: u16, | ||
// TODO: Add doc what these dict maps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: Add doc what these dict maps. | |
// collection name -> list of ontology paths |
// TODO: This is unsafe: not sure what to do though -> maybe block the executor and set env | ||
// variables before this asyn function is started. | ||
// Strange that Rust compiled anyway, without the unsafe block, any idea? | ||
unsafe { | ||
env::set_var( | ||
"RUST_LOG", | ||
"fuzon_http=info,actix_web=warn,actix_server=info", | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: how is this unsafe? If I remove the unsafe directive, everything works fine. This function is in a sync context and we only start the runtime after exporting, right?
@@ -0,0 +1,7 @@ | |||
#[derive(Debug, thiserror::Error, actix_web_error::Json)] | |||
#[status(BAD_REQUEST)] // default status for all variants | |||
pub enum ApiError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
praise: very cool approach 💯
question: iiuc, as we expand the API, we would add variants for the different failure cases to this enum?