Coverage Report

Created: 2024-06-17 06:12

/src/readstat/src/readstat_error.c
Line
Count
Source (jump to first uncovered line)
1
2
#include "readstat.h"
3
4
0
const char *readstat_error_message(readstat_error_t error_code) {
5
0
    if (error_code == READSTAT_OK)
6
0
        return NULL;
7
8
0
    if (error_code == READSTAT_ERROR_OPEN)
9
0
        return "Unable to open file";
10
11
0
    if (error_code == READSTAT_ERROR_READ)
12
0
        return "Unable to read from file";
13
14
0
    if (error_code == READSTAT_ERROR_MALLOC)
15
0
        return "Unable to allocate memory";
16
17
0
    if (error_code == READSTAT_ERROR_USER_ABORT)
18
0
        return "The parsing was aborted (callback returned non-zero value)";
19
20
0
    if (error_code == READSTAT_ERROR_PARSE)
21
0
        return "Invalid file, or file has unsupported features";
22
23
0
    if (error_code == READSTAT_ERROR_UNSUPPORTED_COMPRESSION)
24
0
        return "File has unsupported compression scheme";
25
26
0
    if (error_code == READSTAT_ERROR_UNSUPPORTED_CHARSET)
27
0
        return "File has an unsupported character set";
28
29
0
    if (error_code == READSTAT_ERROR_COLUMN_COUNT_MISMATCH)
30
0
        return "File did not contain the expected number of columns";
31
32
0
    if (error_code == READSTAT_ERROR_ROW_COUNT_MISMATCH)
33
0
        return "File did not contain the expected number of rows";
34
35
0
    if (error_code == READSTAT_ERROR_ROW_WIDTH_MISMATCH)
36
0
        return "A row in the file was not the expected length";
37
38
0
    if (error_code == READSTAT_ERROR_BAD_FORMAT_STRING)
39
0
        return "A provided format string could not be understood";
40
41
0
    if (error_code == READSTAT_ERROR_VALUE_TYPE_MISMATCH)
42
0
        return "A provided value was incompatible with the variable's declared type";
43
44
0
    if (error_code == READSTAT_ERROR_WRITE)
45
0
        return "Unable to write data";
46
    
47
0
    if (error_code == READSTAT_ERROR_WRITER_NOT_INITIALIZED)
48
0
        return "The writer object was not properly initialized (call and check return value of readstat_begin_writing_XXX)";
49
50
0
    if (error_code == READSTAT_ERROR_SEEK)
51
0
        return "Unable to seek within file";
52
53
0
    if (error_code == READSTAT_ERROR_CONVERT)
54
0
        return "Unable to convert string to the requested encoding";
55
56
0
    if (error_code == READSTAT_ERROR_CONVERT_BAD_STRING)
57
0
        return "Unable to convert string to the requested encoding (invalid byte sequence)";
58
59
0
    if (error_code == READSTAT_ERROR_CONVERT_SHORT_STRING)
60
0
        return "Unable to convert string to the requested encoding (incomplete byte sequence)";
61
62
0
    if (error_code == READSTAT_ERROR_CONVERT_LONG_STRING)
63
0
        return "Unable to convert string to the requested encoding (output buffer too small)";
64
65
0
    if (error_code == READSTAT_ERROR_NUMERIC_VALUE_IS_OUT_OF_RANGE)
66
0
        return "A provided numeric value was outside the range of representable values in the specified file format";
67
68
0
    if (error_code == READSTAT_ERROR_TAGGED_VALUE_IS_OUT_OF_RANGE)
69
0
        return "A provided tag value was outside the range of allowed values in the specified file format";
70
71
0
    if (error_code == READSTAT_ERROR_STRING_VALUE_IS_TOO_LONG)
72
0
        return "A provided string value was longer than the available storage size of the specified column";
73
74
0
    if (error_code == READSTAT_ERROR_TAGGED_VALUES_NOT_SUPPORTED)
75
0
        return "The file format does not supported character tags for missing values";
76
77
0
    if (error_code == READSTAT_ERROR_UNSUPPORTED_FILE_FORMAT_VERSION)
78
0
        return "This version of the file format is not supported";
79
80
0
    if (error_code == READSTAT_ERROR_NAME_BEGINS_WITH_ILLEGAL_CHARACTER)
81
0
        return "A provided name begins with an illegal character";
82
83
0
    if (error_code == READSTAT_ERROR_NAME_CONTAINS_ILLEGAL_CHARACTER)
84
0
        return "A provided name contains an illegal character";
85
86
0
    if (error_code == READSTAT_ERROR_NAME_IS_RESERVED_WORD)
87
0
        return "A provided name is a reserved word";
88
89
0
    if (error_code == READSTAT_ERROR_NAME_IS_TOO_LONG)
90
0
        return "A provided name is too long for the file format";
91
92
0
    if (error_code == READSTAT_ERROR_NAME_IS_ZERO_LENGTH)
93
0
        return "A provided name is blank or empty";
94
95
0
    if (error_code == READSTAT_ERROR_BAD_TIMESTAMP_STRING)
96
0
        return "The file's timestamp string is invalid";
97
98
0
    if (error_code == READSTAT_ERROR_BAD_FREQUENCY_WEIGHT)
99
0
        return "The provided variable can't be used as a frequency weight";
100
101
0
    if (error_code == READSTAT_ERROR_TOO_MANY_MISSING_VALUE_DEFINITIONS)
102
0
        return "The number of defined missing values exceeds the format limit";
103
104
0
    if (error_code == READSTAT_ERROR_NOTE_IS_TOO_LONG)
105
0
        return "The provided note is too long for the file format";
106
107
0
    if (error_code == READSTAT_ERROR_STRING_REFS_NOT_SUPPORTED)
108
0
        return "This version of the file format does not support string references";
109
110
0
    if (error_code == READSTAT_ERROR_STRING_REF_IS_REQUIRED)
111
0
        return "The provided value was not a valid string reference";
112
113
0
    if (error_code == READSTAT_ERROR_ROW_IS_TOO_WIDE_FOR_PAGE)
114
0
        return "A row of data will not fit into the file format";
115
116
0
    if (error_code == READSTAT_ERROR_TOO_FEW_COLUMNS)
117
0
        return "One or more columns must be provided";
118
119
0
    if (error_code == READSTAT_ERROR_TOO_MANY_COLUMNS)
120
0
        return "Too many columns for this file format version";
121
122
0
    if (error_code == READSTAT_ERROR_BAD_TIMESTAMP_VALUE)
123
0
        return "The provided file timestamp is invalid";
124
125
0
    return "Unknown error";
126
0
}