Skip to content

Add README.md#2

Open
davidebeatrici wants to merge 2 commits into
masterfrom
readme.md
Open

Add README.md#2
davidebeatrici wants to merge 2 commits into
masterfrom
readme.md

Conversation

@davidebeatrici

Copy link
Copy Markdown
Member

No description provided.

@Krzmbrzl Krzmbrzl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few thoughts I had on a first glance

Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md
`endpoint` can be filled in order to use a specific source endpoint.
Especially useful when you have multiple Internet connections and want to force a specific one.

Returns an [`std::pair`](https://en.cppreference.com/w/cpp/utility/pair) containing the result code and a socket handle (also called "file descriptor").

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems odd. We are writing C++ and thus errors should be communicated by means of exceptions and not via result codes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Honestly, I've ever only used exceptions when strictly required, either by the standard library or an external one.

The "modern" way would be to use std::expected, as it's officially introduced in C++23.
A potential alternative is Boost.Outcome.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Exceptions are still the best way of error handling, imo as they can't be ignored. They have to be handled or else the program terminates. It is unfortunate that C++ compilers don't warn you about potentially unhandled exceptions, though 🤷

Using monads is not necessarily the "modern" way of doing things. It's just another way.
However, since we don't have monads yet anyway, I would argue that exceptions are the best thing we got for the moment (certainly much better than error codes)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would argue it also depends on the way they're presented, in this library the behavior is very consistent.

On the other hand, unhandled exceptions generally trigger an automatic backtrace, which may be desiderable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Even if the error codes are very consistently returned, it is just so easy to forget to check them. I've seen and also experienced this so many times and the result of that is a program that doesn't do error checking, which more often than not will lead to the program crashing somewhere down the line and then it will be much more difficult to figure out where the error came from. With exceptions, you get a crash right when and where the error appears (if you don't handle it).

davidebeatrici and others added 2 commits October 4, 2022 02:08
For clarity, as without the prefix another value could be expected instead.
For example, the amount of bytes added in the case of Crypt::padding().

Co-authored-by: Robert Adam <dev@robert-adam.de>
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.

2 participants