Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"}});
Copy link
Collaborator

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?

Copy link
Author

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.
image

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to change this.

Copy link
Author

Choose a reason for hiding this comment

The 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..
also: on windows, the program crashes for every stupid error like putting a non existant model filename.
that just plain wrong.
all exceptions should be caught. mine was only an example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

} catch (...) {
// Catch all other exceptions
LOG_ERROR("unable to load model", {{"error", "Unknown Exception"}});
return 1;
}

LOG_INFO("model loaded", {});
Expand Down