feat(rpc, net): allow registry + http_router to compile under -fno-exceptions - #2564
Open
genisis0x wants to merge 2 commits into
Open
feat(rpc, net): allow registry + http_router to compile under -fno-exceptions#2564genisis0x wants to merge 2 commits into
genisis0x wants to merge 2 commits into
Conversation
…ceptions Closes stephenberry#2265. `registry::call` has three `try`/`catch` blocks (REPE message-based, REPE span-based, and JSON-RPC) wrapping the registered handler invocation `it->second(state)`. Transitively the registry pulls in `net/http_router.hpp`, which has one `try`/`catch` (route registration error reporting) and three `throw std::runtime_error` sites for route misuse (parameter-name conflict, wildcard-not-last, wildcard-name conflict). Under `-fno-exceptions` none of this compiles, so the rpc registry could not be used in exception-free projects at all — the scenario the reporter described. Guard every site with `#if __cpp_exceptions`, matching the convention used in `glaze_exceptions.hpp`, `core_exceptions.hpp`, and `cli_menu.hpp`: - registry.hpp: when exceptions are off, the catch is elided and the handler is invoked directly; any exception escaping user code in that mode is UB per the `-fno-exceptions` contract. - http_router.hpp `add(...)`: when exceptions are off the routing install is performed without try-coverage; misuse below still surfaces on stderr via the `#else` branches. - http_router.hpp three misuse `throw`s: under `-fno-exceptions` each becomes `fprintf(stderr, ...)` + `std::abort()`. Misconfiguration is fatal but loud, which matches the existing throw behaviour for callers that did not catch. Verified with `clang++ -std=c++23 -fno-exceptions` on the four registry/http_router headers; default with-exceptions build path is token-identical to before.
Previous run timed out in http_client_test (test stephenberry#77/94) on Windows clang-cl. This PR does not touch http_client; the test is independent and consistently passes on main. Forcing a fresh build run.
Contributor
Author
|
Heads up on the red Happy to rebase onto develop after #2544 settled if that helps a re-run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix
`registry.hpp` — three sites
`http_router.hpp` — four sites
Verification
```
clang++ -std=c++23 -fno-exceptions -Iinclude /tmp/glaze_noexc_check.cpp -o /tmp/glaze_noexc_check
(formerly: "cannot use 'try' with exceptions disabled" x4 + "cannot use 'throw' with exceptions disabled" x3)
now: clean build, exit 0
```
Default with-exceptions build: token-identical to before this commit (the `#else` branches only activate under `-fno-exceptions`). Local `jsonrpc_test` and `repe_test` rebuild and link unchanged.
Compatibility