Skip to content

Remove error namespace#18

Merged
annihilatorq merged 1 commit into
mainfrom
refactor/remove-error-namespace
May 22, 2026
Merged

Remove error namespace#18
annihilatorq merged 1 commit into
mainfrom
refactor/remove-error-namespace

Conversation

@annihilatorq
Copy link
Copy Markdown
Member

In the initial design, I based the implementation on the error namespace because that was the established practice in asio. Looking at the library now, there is a conceptual difference between aero and asio: asio uses a regular enum, which causes its errors to propagate to namespace error, making error handling as pleasant and familiar as possible: asio::error::not_connected, whereas aero uses an enum class. I suspect that asio uses regular enums because enum classes were introduced in C++11, and asio needs to support earlier standards. In the end, it seems to me that, to maintain a consistent API, the decision was made not to switch to enum classes at all after C++11 (which isn’t so bad, but I think it just complicates the naming of error codes).

What I'm getting at is this: this PR eliminates the need for users to write something like websocket::error::handshake_error::status_code_invalid,
allowing them to shorten the code to
websocket::handshake_error::status_code_invalid.
And while this is still isn't short, it's clearly the best compromise between readability and simplicity at this point.

@annihilatorq annihilatorq merged commit 2006192 into main May 22, 2026
19 checks passed
@annihilatorq annihilatorq deleted the refactor/remove-error-namespace branch May 22, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant