TokTok / c-toxcore

The future of online communications.
https://tox.chat
GNU General Public License v3.0
2.25k stars 284 forks source link

feat: Add canonical error codes for generic error handling. #2711

Open iphydf opened 7 months ago

iphydf commented 7 months ago

Every error enum should have a conversion function to the canonical codes list. This can make client code more resilient to additions of error codes to per-function error enums, and simplify much of the error handling that currently needs to switch() over each error enum separately.

It's still useful to have additional information from the per-function error enums to present the user with better error messages, but for programmatic error handling (e.g. bots), the canonical codes should always be sufficient context.


This change is Reviewable

codecov[bot] commented 7 months ago

Codecov Report

Attention: Patch coverage is 0% with 28 lines in your changes are missing coverage. Please review.

Project coverage is 73.05%. Comparing base (77e0887) to head (e8b2925). Report is 41 commits behind head on master.

Files Patch % Lines
toxcore/tox_api.c 0.00% 28 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #2711 +/- ## ======================================= Coverage 73.05% 73.05% ======================================= Files 149 149 Lines 30517 30545 +28 ======================================= + Hits 22293 22314 +21 - Misses 8224 8231 +7 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.