]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | * Shared error messages: declarations and macros | |
3 | * | |
4 | * Error messages are accessed through macros with fine-grained, explicit | |
5 | * error message distinctions. Concrete error messages are selected by the | |
6 | * macros and multiple macros can map to the same concrete string to save | |
7 | * on code footprint. This allows flexible footprint/verbosity tuning with | |
8 | * minimal code impact. There are a few limitations to this approach: | |
9 | * (1) switching between plain messages and format strings doesn't work | |
10 | * conveniently, and (2) conditional strings are a bit awkward to handle. | |
11 | * | |
12 | * Because format strings behave differently in the call site (they need to | |
13 | * be followed by format arguments), they have a special prefix (DUK_STR_FMT_ | |
14 | * and duk_str_fmt_). | |
15 | * | |
16 | * On some compilers using explicit shared strings is preferable; on others | |
17 | * it may be better to use straight literals because the compiler will combine | |
18 | * them anyway, and such strings won't end up unnecessarily in a symbol table. | |
19 | */ | |
20 | ||
21 | #ifndef DUK_ERRMSG_H_INCLUDED | |
22 | #define DUK_ERRMSG_H_INCLUDED | |
23 | ||
24 | #define DUK_STR_INTERNAL_ERROR duk_str_internal_error | |
25 | #define DUK_STR_INVALID_COUNT duk_str_invalid_count | |
26 | #define DUK_STR_INVALID_CALL_ARGS duk_str_invalid_call_args | |
27 | #define DUK_STR_NOT_CONSTRUCTABLE duk_str_not_constructable | |
28 | #define DUK_STR_NOT_CALLABLE duk_str_not_callable | |
29 | #define DUK_STR_NOT_EXTENSIBLE duk_str_not_extensible | |
30 | #define DUK_STR_NOT_WRITABLE duk_str_not_writable | |
31 | #define DUK_STR_NOT_CONFIGURABLE duk_str_not_configurable | |
32 | ||
33 | #if !defined(DUK_SINGLE_FILE) | |
34 | DUK_INTERNAL_DECL const char *duk_str_internal_error; | |
35 | DUK_INTERNAL_DECL const char *duk_str_invalid_count; | |
36 | DUK_INTERNAL_DECL const char *duk_str_invalid_call_args; | |
37 | DUK_INTERNAL_DECL const char *duk_str_not_constructable; | |
38 | DUK_INTERNAL_DECL const char *duk_str_not_callable; | |
39 | DUK_INTERNAL_DECL const char *duk_str_not_extensible; | |
40 | DUK_INTERNAL_DECL const char *duk_str_not_writable; | |
41 | DUK_INTERNAL_DECL const char *duk_str_not_configurable; | |
42 | #endif /* !DUK_SINGLE_FILE */ | |
43 | ||
44 | #define DUK_STR_INVALID_CONTEXT duk_str_invalid_context | |
11fdf7f2 | 45 | #define DUK_STR_INVALID_INDEX duk_str_invalid_call_args |
7c673cae | 46 | #define DUK_STR_PUSH_BEYOND_ALLOC_STACK duk_str_push_beyond_alloc_stack |
11fdf7f2 TL |
47 | #define DUK_STR_NOT_UNDEFINED duk_str_unexpected_type |
48 | #define DUK_STR_NOT_NULL duk_str_unexpected_type | |
49 | #define DUK_STR_NOT_BOOLEAN duk_str_unexpected_type | |
50 | #define DUK_STR_NOT_NUMBER duk_str_unexpected_type | |
51 | #define DUK_STR_NOT_STRING duk_str_unexpected_type | |
52 | #define DUK_STR_NOT_OBJECT duk_str_unexpected_type | |
53 | #define DUK_STR_NOT_POINTER duk_str_unexpected_type | |
54 | #define DUK_STR_NOT_BUFFER duk_str_not_buffer /* still in use with verbose messages */ | |
7c673cae | 55 | #define DUK_STR_UNEXPECTED_TYPE duk_str_unexpected_type |
11fdf7f2 TL |
56 | #define DUK_STR_NOT_THREAD duk_str_unexpected_type |
57 | #define DUK_STR_NOT_COMPILEDFUNCTION duk_str_unexpected_type | |
58 | #define DUK_STR_NOT_NATIVEFUNCTION duk_str_unexpected_type | |
59 | #define DUK_STR_NOT_C_FUNCTION duk_str_unexpected_type | |
60 | #define DUK_STR_NOT_FUNCTION duk_str_unexpected_type | |
61 | #define DUK_STR_NOT_REGEXP duk_str_unexpected_type | |
7c673cae FG |
62 | #define DUK_STR_DEFAULTVALUE_COERCE_FAILED duk_str_defaultvalue_coerce_failed |
63 | #define DUK_STR_NUMBER_OUTSIDE_RANGE duk_str_number_outside_range | |
64 | #define DUK_STR_NOT_OBJECT_COERCIBLE duk_str_not_object_coercible | |
65 | #define DUK_STR_STRING_TOO_LONG duk_str_string_too_long | |
66 | #define DUK_STR_BUFFER_TOO_LONG duk_str_buffer_too_long | |
67 | #define DUK_STR_SPRINTF_TOO_LONG duk_str_sprintf_too_long | |
68 | #define DUK_STR_ALLOC_FAILED duk_str_alloc_failed | |
69 | #define DUK_STR_POP_TOO_MANY duk_str_pop_too_many | |
70 | #define DUK_STR_WRONG_BUFFER_TYPE duk_str_wrong_buffer_type | |
7c673cae FG |
71 | #define DUK_STR_ENCODE_FAILED duk_str_encode_failed |
72 | #define DUK_STR_DECODE_FAILED duk_str_decode_failed | |
73 | #define DUK_STR_NO_SOURCECODE duk_str_no_sourcecode | |
74 | #define DUK_STR_CONCAT_RESULT_TOO_LONG duk_str_concat_result_too_long | |
75 | #define DUK_STR_UNIMPLEMENTED duk_str_unimplemented | |
76 | #define DUK_STR_UNSUPPORTED duk_str_unsupported | |
77 | #define DUK_STR_ARRAY_LENGTH_OVER_2G duk_str_array_length_over_2g | |
78 | ||
79 | #if !defined(DUK_SINGLE_FILE) | |
80 | DUK_INTERNAL_DECL const char *duk_str_invalid_context; | |
7c673cae | 81 | DUK_INTERNAL_DECL const char *duk_str_push_beyond_alloc_stack; |
7c673cae FG |
82 | DUK_INTERNAL_DECL const char *duk_str_not_buffer; |
83 | DUK_INTERNAL_DECL const char *duk_str_unexpected_type; | |
7c673cae FG |
84 | DUK_INTERNAL_DECL const char *duk_str_defaultvalue_coerce_failed; |
85 | DUK_INTERNAL_DECL const char *duk_str_number_outside_range; | |
86 | DUK_INTERNAL_DECL const char *duk_str_not_object_coercible; | |
87 | DUK_INTERNAL_DECL const char *duk_str_string_too_long; | |
88 | DUK_INTERNAL_DECL const char *duk_str_buffer_too_long; | |
89 | DUK_INTERNAL_DECL const char *duk_str_sprintf_too_long; | |
90 | DUK_INTERNAL_DECL const char *duk_str_alloc_failed; | |
91 | DUK_INTERNAL_DECL const char *duk_str_pop_too_many; | |
92 | DUK_INTERNAL_DECL const char *duk_str_wrong_buffer_type; | |
7c673cae FG |
93 | DUK_INTERNAL_DECL const char *duk_str_encode_failed; |
94 | DUK_INTERNAL_DECL const char *duk_str_decode_failed; | |
95 | DUK_INTERNAL_DECL const char *duk_str_no_sourcecode; | |
96 | DUK_INTERNAL_DECL const char *duk_str_concat_result_too_long; | |
97 | DUK_INTERNAL_DECL const char *duk_str_unimplemented; | |
98 | DUK_INTERNAL_DECL const char *duk_str_unsupported; | |
99 | DUK_INTERNAL_DECL const char *duk_str_array_length_over_2g; | |
100 | #endif /* !DUK_SINGLE_FILE */ | |
101 | ||
102 | #define DUK_STR_FMT_PTR duk_str_fmt_ptr | |
103 | #define DUK_STR_FMT_INVALID_JSON duk_str_fmt_invalid_json | |
104 | #define DUK_STR_JSONDEC_RECLIMIT duk_str_jsondec_reclimit | |
105 | #define DUK_STR_JSONENC_RECLIMIT duk_str_jsonenc_reclimit | |
106 | #define DUK_STR_CYCLIC_INPUT duk_str_cyclic_input | |
107 | ||
108 | #if !defined(DUK_SINGLE_FILE) | |
109 | DUK_INTERNAL_DECL const char *duk_str_fmt_ptr; | |
110 | DUK_INTERNAL_DECL const char *duk_str_fmt_invalid_json; | |
111 | DUK_INTERNAL_DECL const char *duk_str_jsondec_reclimit; | |
112 | DUK_INTERNAL_DECL const char *duk_str_jsonenc_reclimit; | |
113 | DUK_INTERNAL_DECL const char *duk_str_cyclic_input; | |
114 | #endif /* !DUK_SINGLE_FILE */ | |
115 | ||
116 | #define DUK_STR_PROXY_REVOKED duk_str_proxy_revoked | |
7c673cae FG |
117 | #define DUK_STR_INVALID_BASE duk_str_invalid_base |
118 | #define DUK_STR_STRICT_CALLER_READ duk_str_strict_caller_read | |
119 | #define DUK_STR_PROXY_REJECTED duk_str_proxy_rejected | |
120 | #define DUK_STR_INVALID_ARRAY_LENGTH duk_str_invalid_array_length | |
121 | #define DUK_STR_ARRAY_LENGTH_WRITE_FAILED duk_str_array_length_write_failed | |
122 | #define DUK_STR_ARRAY_LENGTH_NOT_WRITABLE duk_str_array_length_not_writable | |
123 | #define DUK_STR_SETTER_UNDEFINED duk_str_setter_undefined | |
124 | #define DUK_STR_REDEFINE_VIRT_PROP duk_str_redefine_virt_prop | |
125 | #define DUK_STR_INVALID_DESCRIPTOR duk_str_invalid_descriptor | |
126 | #define DUK_STR_PROPERTY_IS_VIRTUAL duk_str_property_is_virtual | |
127 | ||
128 | #if !defined(DUK_SINGLE_FILE) | |
129 | DUK_INTERNAL_DECL const char *duk_str_proxy_revoked; | |
7c673cae FG |
130 | DUK_INTERNAL_DECL const char *duk_str_invalid_base; |
131 | DUK_INTERNAL_DECL const char *duk_str_strict_caller_read; | |
132 | DUK_INTERNAL_DECL const char *duk_str_proxy_rejected; | |
133 | DUK_INTERNAL_DECL const char *duk_str_invalid_array_length; | |
134 | DUK_INTERNAL_DECL const char *duk_str_array_length_write_failed; | |
135 | DUK_INTERNAL_DECL const char *duk_str_array_length_not_writable; | |
136 | DUK_INTERNAL_DECL const char *duk_str_setter_undefined; | |
137 | DUK_INTERNAL_DECL const char *duk_str_redefine_virt_prop; | |
138 | DUK_INTERNAL_DECL const char *duk_str_invalid_descriptor; | |
139 | DUK_INTERNAL_DECL const char *duk_str_property_is_virtual; | |
140 | #endif /* !DUK_SINGLE_FILE */ | |
141 | ||
142 | #define DUK_STR_PARSE_ERROR duk_str_parse_error | |
143 | #define DUK_STR_DUPLICATE_LABEL duk_str_duplicate_label | |
144 | #define DUK_STR_INVALID_LABEL duk_str_invalid_label | |
145 | #define DUK_STR_INVALID_ARRAY_LITERAL duk_str_invalid_array_literal | |
146 | #define DUK_STR_INVALID_OBJECT_LITERAL duk_str_invalid_object_literal | |
147 | #define DUK_STR_INVALID_VAR_DECLARATION duk_str_invalid_var_declaration | |
148 | #define DUK_STR_CANNOT_DELETE_IDENTIFIER duk_str_cannot_delete_identifier | |
149 | #define DUK_STR_INVALID_EXPRESSION duk_str_invalid_expression | |
150 | #define DUK_STR_INVALID_LVALUE duk_str_invalid_lvalue | |
151 | #define DUK_STR_EXPECTED_IDENTIFIER duk_str_expected_identifier | |
152 | #define DUK_STR_EMPTY_EXPR_NOT_ALLOWED duk_str_empty_expr_not_allowed | |
153 | #define DUK_STR_INVALID_FOR duk_str_invalid_for | |
154 | #define DUK_STR_INVALID_SWITCH duk_str_invalid_switch | |
155 | #define DUK_STR_INVALID_BREAK_CONT_LABEL duk_str_invalid_break_cont_label | |
156 | #define DUK_STR_INVALID_RETURN duk_str_invalid_return | |
157 | #define DUK_STR_INVALID_TRY duk_str_invalid_try | |
158 | #define DUK_STR_INVALID_THROW duk_str_invalid_throw | |
159 | #define DUK_STR_WITH_IN_STRICT_MODE duk_str_with_in_strict_mode | |
160 | #define DUK_STR_FUNC_STMT_NOT_ALLOWED duk_str_func_stmt_not_allowed | |
161 | #define DUK_STR_UNTERMINATED_STMT duk_str_unterminated_stmt | |
162 | #define DUK_STR_INVALID_ARG_NAME duk_str_invalid_arg_name | |
163 | #define DUK_STR_INVALID_FUNC_NAME duk_str_invalid_func_name | |
164 | #define DUK_STR_INVALID_GETSET_NAME duk_str_invalid_getset_name | |
165 | #define DUK_STR_FUNC_NAME_REQUIRED duk_str_func_name_required | |
166 | ||
167 | #if !defined(DUK_SINGLE_FILE) | |
168 | DUK_INTERNAL_DECL const char *duk_str_parse_error; | |
169 | DUK_INTERNAL_DECL const char *duk_str_duplicate_label; | |
170 | DUK_INTERNAL_DECL const char *duk_str_invalid_label; | |
171 | DUK_INTERNAL_DECL const char *duk_str_invalid_array_literal; | |
172 | DUK_INTERNAL_DECL const char *duk_str_invalid_object_literal; | |
173 | DUK_INTERNAL_DECL const char *duk_str_invalid_var_declaration; | |
174 | DUK_INTERNAL_DECL const char *duk_str_cannot_delete_identifier; | |
175 | DUK_INTERNAL_DECL const char *duk_str_invalid_expression; | |
176 | DUK_INTERNAL_DECL const char *duk_str_invalid_lvalue; | |
177 | DUK_INTERNAL_DECL const char *duk_str_expected_identifier; | |
178 | DUK_INTERNAL_DECL const char *duk_str_empty_expr_not_allowed; | |
179 | DUK_INTERNAL_DECL const char *duk_str_invalid_for; | |
180 | DUK_INTERNAL_DECL const char *duk_str_invalid_switch; | |
181 | DUK_INTERNAL_DECL const char *duk_str_invalid_break_cont_label; | |
182 | DUK_INTERNAL_DECL const char *duk_str_invalid_return; | |
183 | DUK_INTERNAL_DECL const char *duk_str_invalid_try; | |
184 | DUK_INTERNAL_DECL const char *duk_str_invalid_throw; | |
185 | DUK_INTERNAL_DECL const char *duk_str_with_in_strict_mode; | |
186 | DUK_INTERNAL_DECL const char *duk_str_func_stmt_not_allowed; | |
187 | DUK_INTERNAL_DECL const char *duk_str_unterminated_stmt; | |
188 | DUK_INTERNAL_DECL const char *duk_str_invalid_arg_name; | |
189 | DUK_INTERNAL_DECL const char *duk_str_invalid_func_name; | |
190 | DUK_INTERNAL_DECL const char *duk_str_invalid_getset_name; | |
191 | DUK_INTERNAL_DECL const char *duk_str_func_name_required; | |
192 | #endif /* !DUK_SINGLE_FILE */ | |
193 | ||
7c673cae FG |
194 | #define DUK_STR_INVALID_QUANTIFIER_NO_ATOM duk_str_invalid_quantifier_no_atom |
195 | #define DUK_STR_INVALID_QUANTIFIER_VALUES duk_str_invalid_quantifier_values | |
196 | #define DUK_STR_QUANTIFIER_TOO_MANY_COPIES duk_str_quantifier_too_many_copies | |
197 | #define DUK_STR_UNEXPECTED_CLOSING_PAREN duk_str_unexpected_closing_paren | |
198 | #define DUK_STR_UNEXPECTED_END_OF_PATTERN duk_str_unexpected_end_of_pattern | |
199 | #define DUK_STR_UNEXPECTED_REGEXP_TOKEN duk_str_unexpected_regexp_token | |
200 | #define DUK_STR_INVALID_REGEXP_FLAGS duk_str_invalid_regexp_flags | |
201 | #define DUK_STR_INVALID_BACKREFS duk_str_invalid_backrefs | |
7c673cae FG |
202 | |
203 | #if !defined(DUK_SINGLE_FILE) | |
204 | DUK_INTERNAL_DECL const char *duk_str_invalid_quantifier_no_atom; | |
205 | DUK_INTERNAL_DECL const char *duk_str_invalid_quantifier_values; | |
206 | DUK_INTERNAL_DECL const char *duk_str_quantifier_too_many_copies; | |
207 | DUK_INTERNAL_DECL const char *duk_str_unexpected_closing_paren; | |
208 | DUK_INTERNAL_DECL const char *duk_str_unexpected_end_of_pattern; | |
209 | DUK_INTERNAL_DECL const char *duk_str_unexpected_regexp_token; | |
210 | DUK_INTERNAL_DECL const char *duk_str_invalid_regexp_flags; | |
211 | DUK_INTERNAL_DECL const char *duk_str_invalid_backrefs; | |
7c673cae FG |
212 | #endif /* !DUK_SINGLE_FILE */ |
213 | ||
214 | #define DUK_STR_VALSTACK_LIMIT duk_str_valstack_limit | |
215 | #define DUK_STR_CALLSTACK_LIMIT duk_str_callstack_limit | |
216 | #define DUK_STR_CATCHSTACK_LIMIT duk_str_catchstack_limit | |
7c673cae FG |
217 | #define DUK_STR_PROTOTYPE_CHAIN_LIMIT duk_str_prototype_chain_limit |
218 | #define DUK_STR_BOUND_CHAIN_LIMIT duk_str_bound_chain_limit | |
219 | #define DUK_STR_C_CALLSTACK_LIMIT duk_str_c_callstack_limit | |
220 | #define DUK_STR_COMPILER_RECURSION_LIMIT duk_str_compiler_recursion_limit | |
221 | #define DUK_STR_BYTECODE_LIMIT duk_str_bytecode_limit | |
222 | #define DUK_STR_REG_LIMIT duk_str_reg_limit | |
223 | #define DUK_STR_TEMP_LIMIT duk_str_temp_limit | |
224 | #define DUK_STR_CONST_LIMIT duk_str_const_limit | |
225 | #define DUK_STR_FUNC_LIMIT duk_str_func_limit | |
226 | #define DUK_STR_REGEXP_COMPILER_RECURSION_LIMIT duk_str_regexp_compiler_recursion_limit | |
227 | #define DUK_STR_REGEXP_EXECUTOR_RECURSION_LIMIT duk_str_regexp_executor_recursion_limit | |
228 | #define DUK_STR_REGEXP_EXECUTOR_STEP_LIMIT duk_str_regexp_executor_step_limit | |
229 | ||
230 | #if !defined(DUK_SINGLE_FILE) | |
231 | DUK_INTERNAL_DECL const char *duk_str_valstack_limit; | |
232 | DUK_INTERNAL_DECL const char *duk_str_callstack_limit; | |
233 | DUK_INTERNAL_DECL const char *duk_str_catchstack_limit; | |
7c673cae FG |
234 | DUK_INTERNAL_DECL const char *duk_str_prototype_chain_limit; |
235 | DUK_INTERNAL_DECL const char *duk_str_bound_chain_limit; | |
236 | DUK_INTERNAL_DECL const char *duk_str_c_callstack_limit; | |
237 | DUK_INTERNAL_DECL const char *duk_str_compiler_recursion_limit; | |
238 | DUK_INTERNAL_DECL const char *duk_str_bytecode_limit; | |
239 | DUK_INTERNAL_DECL const char *duk_str_reg_limit; | |
240 | DUK_INTERNAL_DECL const char *duk_str_temp_limit; | |
241 | DUK_INTERNAL_DECL const char *duk_str_const_limit; | |
242 | DUK_INTERNAL_DECL const char *duk_str_func_limit; | |
243 | DUK_INTERNAL_DECL const char *duk_str_regexp_compiler_recursion_limit; | |
244 | DUK_INTERNAL_DECL const char *duk_str_regexp_executor_recursion_limit; | |
245 | DUK_INTERNAL_DECL const char *duk_str_regexp_executor_step_limit; | |
246 | #endif /* !DUK_SINGLE_FILE */ | |
247 | ||
7c673cae FG |
248 | #if !defined(DUK_SINGLE_FILE) |
249 | DUK_INTERNAL_DECL const char *duk_str_anon; | |
7c673cae FG |
250 | #endif /* !DUK_SINGLE_FILE */ |
251 | ||
252 | #endif /* DUK_ERRMSG_H_INCLUDED */ |