blob: 08051e7dbe2f3f1f14cd1bb5ee959c4b76c44735 [file] [log] [blame]
James Kuszmaul28cc8252021-01-17 11:32:21 -08001#pragma once
2
3/// Return codes.
4///
5/// To make it easy to test for errors, the *success* return code's
6/// value will always be `0`. Therefore, you can test for errors
7/// in the following way:
8///
9/// enum rawrtc_code const error = rawrtc_some_function();
10/// if (error) {
11/// // Handle the error...
12/// }
13///
14/// **Important**: Add translations for new return codes in
15/// `utils/utils.c`!
16enum rawrtc_code {
17 /// An unknown (or non-translatable) error occurred.
18 RAWRTC_CODE_UNKNOWN_ERROR = -2,
19 /// The necessary functionality has not been implemented.
20 RAWRTC_CODE_NOT_IMPLEMENTED = -1,
21 /// Success! Nothing went wrong - you're fine to proceed.
22 RAWRTC_CODE_SUCCESS = 0,
23 /// Initialisation failed.
24 RAWRTC_CODE_INITIALISE_FAIL,
25 /// Invalid argument.
26 RAWRTC_CODE_INVALID_ARGUMENT,
27 /// Memory could not be allocated.
28 RAWRTC_CODE_NO_MEMORY,
29 /// Invalid state.
30 RAWRTC_CODE_INVALID_STATE,
31 /// Unsupported protocol.
32 RAWRTC_CODE_UNSUPPORTED_PROTOCOL,
33 /// Unsupported algorithm.
34 RAWRTC_CODE_UNSUPPORTED_ALGORITHM,
35 /// No value has been set.
36 /// @note This is often used for functions that change the value of
37 /// a variable declared outside of the function to indicate
38 /// that no change occurred.
39 RAWRTC_CODE_NO_VALUE,
40 /// Socket could not be found.
41 RAWRTC_CODE_NO_SOCKET,
42 /// Invalid certificate.
43 RAWRTC_CODE_INVALID_CERTIFICATE,
44 /// Invalid fingerprint.
45 RAWRTC_CODE_INVALID_FINGERPRINT,
46 /// Insufficient space.
47 RAWRTC_CODE_INSUFFICIENT_SPACE,
48 /// Target is still being used.
49 RAWRTC_CODE_STILL_IN_USE,
50 /// Invalid message.
51 RAWRTC_CODE_INVALID_MESSAGE,
52 /// Message is too long.
53 RAWRTC_CODE_MESSAGE_TOO_LONG,
54 /// Try again later.
55 /// @note This is semantically equivalent to `EAGAIN` and
56 /// `EWOULDBLOCK`.
57 RAWRTC_CODE_TRY_AGAIN_LATER,
58 /// Stopped iterating (early).
59 RAWRTC_CODE_STOP_ITERATION,
60 /// Operation not permitted.
61 RAWRTC_CODE_NOT_PERMITTED,
62 /// An external function returned an error.
63 RAWRTC_CODE_EXTERNAL_ERROR,
64};