1 /*
2 ** SPDX-License-Identifier: BSD-3-Clause
3 ** Copyright Contributors to the OpenEXR Project.
4 */
5 
6 #ifndef OPENEXR_ERRORS_H
7 #define OPENEXR_ERRORS_H
8 
9 #include "openexr_conf.h"
10 
11 #include <stdint.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /** @file */
18 
19 /**
20  * @defgroup ErrorCodes Error Handling
21  * @brief These are a group of definitions related to error handling.
22  *
23  * All functions in the C layer will return a result, which will
24  * correspond to one of these codes. To ensure binary stability, the
25  * return type is separate from the error code, and is a fixed size.
26  *
27  * @{
28  */
29 
30 /** Error codes that may be returned by various functions. */
31 typedef enum
32 {
33     EXR_ERR_SUCCESS = 0,
34     EXR_ERR_OUT_OF_MEMORY,
35     EXR_ERR_MISSING_CONTEXT_ARG,
36     EXR_ERR_INVALID_ARGUMENT,
37     EXR_ERR_ARGUMENT_OUT_OF_RANGE,
38     EXR_ERR_FILE_ACCESS,
39     EXR_ERR_FILE_BAD_HEADER,
40     EXR_ERR_NOT_OPEN_READ,
41     EXR_ERR_NOT_OPEN_WRITE,
42     EXR_ERR_HEADER_NOT_WRITTEN,
43     EXR_ERR_READ_IO,
44     EXR_ERR_WRITE_IO,
45     EXR_ERR_NAME_TOO_LONG,
46     EXR_ERR_MISSING_REQ_ATTR,
47     EXR_ERR_INVALID_ATTR,
48     EXR_ERR_NO_ATTR_BY_NAME,
49     EXR_ERR_ATTR_TYPE_MISMATCH,
50     EXR_ERR_ATTR_SIZE_MISMATCH,
51     EXR_ERR_SCAN_TILE_MIXEDAPI,
52     EXR_ERR_TILE_SCAN_MIXEDAPI,
53     EXR_ERR_MODIFY_SIZE_CHANGE,
54     EXR_ERR_ALREADY_WROTE_ATTRS,
55     EXR_ERR_BAD_CHUNK_LEADER,
56     EXR_ERR_CORRUPT_CHUNK,
57     EXR_ERR_INCORRECT_PART,
58     EXR_ERR_INCORRECT_CHUNK,
59     EXR_ERR_USE_SCAN_DEEP_WRITE,
60     EXR_ERR_USE_TILE_DEEP_WRITE,
61     EXR_ERR_USE_SCAN_NONDEEP_WRITE,
62     EXR_ERR_USE_TILE_NONDEEP_WRITE,
63     EXR_ERR_INVALID_SAMPLE_DATA,
64     EXR_ERR_FEATURE_NOT_IMPLEMENTED,
65     EXR_ERR_UNKNOWN
66 } exr_error_code_t;
67 
68 /** Return type for all functions. */
69 typedef int32_t exr_result_t;
70 
71 /** @brief Return a static string corresponding to the specified error code.
72  *
73  * The string should not be freed (it is compiled into the binary).
74  */
75 EXR_EXPORT const char* exr_get_default_error_message (exr_result_t code);
76 
77 /** @brief Return a static string corresponding to the specified error code.
78  *
79  * The string should not be freed (it is compiled into the binary).
80  */
81 EXR_EXPORT const char* exr_get_error_code_as_string (exr_result_t code);
82 
83 /** @} */
84 
85 #ifdef __cplusplus
86 } /* extern "C" */
87 #endif
88 
89 #endif /* OPENEXR_ERRORS_H */
90