-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Catch exceptions correctly in server.cpp #7642
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
Changes from all commits
0001ec3
0d358c1
1ac70ba
4d78cff
8dc6f16
48b860a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3039,13 +3039,25 @@ int main(int argc, char ** argv) { | |
| log_data["api_key"] = "api_key: " + std::to_string(sparams.api_keys.size()) + " keys loaded"; | ||
| } | ||
|
|
||
| // load the model | ||
| if (!ctx_server.load_model(params)) { | ||
| state.store(SERVER_STATE_ERROR); | ||
| return 1; | ||
| } else { | ||
| try { | ||
| // Attempt to load the model | ||
| if (!ctx_server.load_model(params)) { | ||
| LOG_ERROR("unable to load model", {{"error", "Load model failed"}}); | ||
| state.store(SERVER_STATE_ERROR); | ||
| return 1; | ||
| } | ||
| // Initialize the server context if the model is loaded successfully | ||
| ctx_server.init(); | ||
| state.store(SERVER_STATE_READY); | ||
|
|
||
| } catch (const std::exception &e) { | ||
| // Catch known standard exceptions | ||
| LOG_ERROR("unable to load model", {{"error", e.what()}}); | ||
| exit(1); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You forgot to change this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok.. I give up... 3 days and still nothing for a simple modification.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| } catch (...) { | ||
| // Catch all other exceptions | ||
| LOG_ERROR("unable to load model", {{"error", "Unknown Exception"}}); | ||
| return 1; | ||
| } | ||
|
|
||
| LOG_INFO("model loaded", {}); | ||
|
|
||

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.
Here is why it makes no sense to me: we already catch the
unable to load model. Why do we need another try..catch to do that?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.
because if you do: server -m nonexistantfile the program couses a windows CRASH instead of just exiting with the error.
