Skip to content

Conversation

@cwaldren-ld
Copy link
Contributor

@cwaldren-ld cwaldren-ld commented Mar 30, 2023

Pulls in the tl::expected library for error handling. The idea is that we can return value types, as well as an error code from functions. I believe something similar is slated for std::.

It has nice things like map built in.

I'm not 100% all in on having a single Error enum, I just thought it'd be simpler to ensure unique unique error codes from a C standpoint.

enum class Error : std::uint32_t {
KReserved1 = 0,
KReserved2 = 1,
/* Common lib errors: 2-99 */
Copy link
Contributor Author

@cwaldren-ld cwaldren-ld Mar 30, 2023

Choose a reason for hiding this comment

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

In case we decide to do:

  • some kind of casting to LDBoolean (0/1)
  • Generic success
  • Generic failure

I've just reserved the first two values.

/* Client-side errors: 100-199 */
/* Server-side errors: 200-299 */

kMax = std::numeric_limits<std::uint32_t>::max()
Copy link
Contributor Author

@cwaldren-ld cwaldren-ld Mar 30, 2023

Choose a reason for hiding this comment

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

kMax is just here to make us remember to do something similar in C, to help with ABI stability as we add new values in the future.

@cwaldren-ld cwaldren-ld marked this pull request as ready for review March 30, 2023 23:50
@cwaldren-ld cwaldren-ld requested a review from kinyoklion March 30, 2023 23:50
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.

3 participants