Skip to content

Commit 3053e02

Browse files
committed
Don't use messages for errors by default
Use empty string for message property of builtin error objects by default. Add ERROR_MESSAGES build option. JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
1 parent ce2fc3c commit 3053e02

37 files changed

+166
-148
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ project (Jerry C ASM)
5656
option(ENABLE_LTO "Enable LTO build" ON)
5757
option(ENABLE_LOG "Enable LOG build" OFF)
5858
option(ENABLE_ALL_IN_ONE "Enable ALL_IN_ONE build" OFF)
59+
option(ENABLE_ERROR_MESSAGES "Enable error messages for builtin error objects" OFF)
5960

6061
if("${PLATFORM}" STREQUAL "LINUX")
6162
set(PLATFORM_EXT "LINUX")

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ BUILD_NAME:=
8080
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_DATE_SYS_CALLS=$(DATE_SYS_CALLS)
8181
endif
8282

83+
# Fill error messages for builtin error objects
84+
ifneq ($(ERROR_MESSAGES),)
85+
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_ERROR_MESSAGES=$(ERROR_MESSAGES)
86+
endif
87+
8388
# All-in-one build
8489
ifneq ($(ALL_IN_ONE),)
8590
CMAKE_DEFINES:=$(CMAKE_DEFINES) -DENABLE_ALL_IN_ONE=$(ALL_IN_ONE)

jerry-core/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ project (JerryCore C ASM)
190190
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_DATE_SYS_CALLS)
191191
endif()
192192

193+
# Fill error messages for builtin error objects
194+
if("${ENABLE_ERROR_MESSAGES}" STREQUAL "ON")
195+
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_ERROR_MESSAGES)
196+
endif()
197+
193198
# Platform-specific configuration
194199
set(DEFINES_JERRY ${DEFINES_JERRY} ${DEFINES_JERRY_${PLATFORM_EXT}})
195200

jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum
12011201
/* Check if the provided compare function is callable. */
12021202
if (!ecma_is_value_undefined (arg1) && !ecma_op_is_callable (arg1))
12031203
{
1204-
return ecma_raise_type_error ("");
1204+
return ecma_raise_type_error (ECMA_ERR_MSG (""));
12051205
}
12061206

12071207
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
@@ -2015,7 +2015,7 @@ ecma_builtin_array_prototype_object_every (ecma_value_t this_arg, /**< this argu
20152015
/* 4. */
20162016
if (!ecma_op_is_callable (arg1))
20172017
{
2018-
ret_value = ecma_raise_type_error ("");
2018+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
20192019
}
20202020
else
20212021
{
@@ -2116,7 +2116,7 @@ ecma_builtin_array_prototype_object_some (ecma_value_t this_arg, /**< this argum
21162116
/* 4. */
21172117
if (!ecma_op_is_callable (arg1))
21182118
{
2119-
ret_value = ecma_raise_type_error ("");
2119+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
21202120
}
21212121
else
21222122
{
@@ -2216,7 +2216,7 @@ ecma_builtin_array_prototype_object_for_each (ecma_value_t this_arg, /**< this a
22162216
/* 4. */
22172217
if (!ecma_op_is_callable (arg1))
22182218
{
2219-
ret_value = ecma_raise_type_error ("");
2219+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
22202220
}
22212221
else
22222222
{
@@ -2311,7 +2311,7 @@ ecma_builtin_array_prototype_object_map (ecma_value_t this_arg, /**< this argume
23112311
/* 4. */
23122312
if (!ecma_op_is_callable (arg1))
23132313
{
2314-
ret_value = ecma_raise_type_error ("");
2314+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
23152315
}
23162316
else
23172317
{
@@ -2425,7 +2425,7 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t this_arg, /**< this arg
24252425
/* 4. */
24262426
if (!ecma_op_is_callable (arg1))
24272427
{
2428-
ret_value = ecma_raise_type_error ("");
2428+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
24292429
}
24302430
else
24312431
{
@@ -2550,7 +2550,7 @@ ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this arg
25502550
/* 4. */
25512551
if (!ecma_op_is_callable (callbackfn))
25522552
{
2553-
ret_value = ecma_raise_type_error ("");
2553+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
25542554
}
25552555
else
25562556
{
@@ -2564,7 +2564,7 @@ ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this arg
25642564
/* 5. */
25652565
if (len_number == ECMA_NUMBER_ZERO && ecma_is_value_undefined (initial_value))
25662566
{
2567-
ret_value = ecma_raise_type_error ("");
2567+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
25682568
}
25692569
else
25702570
{
@@ -2601,7 +2601,7 @@ ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this arg
26012601
/* 8.c */
26022602
if (!k_present)
26032603
{
2604-
ret_value = ecma_raise_type_error ("");
2604+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
26052605
}
26062606
}
26072607
/* 9. */
@@ -2695,7 +2695,7 @@ ecma_builtin_array_prototype_object_reduce_right (ecma_value_t this_arg, /**< th
26952695
/* 4. */
26962696
if (!ecma_op_is_callable (callbackfn))
26972697
{
2698-
ret_value = ecma_raise_type_error ("");
2698+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
26992699
}
27002700
else
27012701
{
@@ -2707,7 +2707,7 @@ ecma_builtin_array_prototype_object_reduce_right (ecma_value_t this_arg, /**< th
27072707
/* 5. */
27082708
if (len_number == ECMA_NUMBER_ZERO && ecma_is_value_undefined (initial_value))
27092709
{
2710-
ret_value = ecma_raise_type_error ("");
2710+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
27112711
}
27122712
else
27132713
{
@@ -2747,7 +2747,7 @@ ecma_builtin_array_prototype_object_reduce_right (ecma_value_t this_arg, /**< th
27472747
/* 8.c */
27482748
if (!k_present)
27492749
{
2750-
ret_value = ecma_raise_type_error ("");
2750+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
27512751
}
27522752
}
27532753
/* 9. */

jerry-core/ecma/builtin-objects/ecma-builtin-boolean-prototype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ ecma_builtin_boolean_prototype_object_value_of (ecma_value_t this_arg) /**< this
119119
}
120120
}
121121

122-
return ecma_raise_type_error ("");
122+
return ecma_raise_type_error (ECMA_ERR_MSG (""));
123123
} /* ecma_builtin_boolean_prototype_object_value_of */
124124

125125
/**

jerry-core/ecma/builtin-objects/ecma-builtin-date-prototype.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ecma_builtin_date_prototype_to_date_string (ecma_value_t this_arg) /**< this arg
9595
if (!ecma_is_value_object (this_arg)
9696
|| ecma_object_get_class_name (ecma_get_object_from_value (this_arg)) != LIT_MAGIC_STRING_DATE_UL)
9797
{
98-
ret_value = ecma_raise_type_error ("Incompatible type");
98+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incompatible type"));
9999
}
100100
else
101101
{
@@ -142,7 +142,7 @@ ecma_builtin_date_prototype_to_time_string (ecma_value_t this_arg) /**< this arg
142142
if (!ecma_is_value_object (this_arg)
143143
|| ecma_object_get_class_name (ecma_get_object_from_value (this_arg)) != LIT_MAGIC_STRING_DATE_UL)
144144
{
145-
ret_value = ecma_raise_type_error ("Incompatible type");
145+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incompatible type"));
146146
}
147147
else
148148
{
@@ -262,7 +262,7 @@ ecma_builtin_date_prototype_get_time (ecma_value_t this_arg) /**< this argument
262262
}
263263
}
264264

265-
return ecma_raise_type_error ("");
265+
return ecma_raise_type_error (ECMA_ERR_MSG (""));
266266
} /* ecma_builtin_date_prototype_get_time */
267267

268268
/**
@@ -350,7 +350,7 @@ ecma_builtin_date_prototype_set_time (ecma_value_t this_arg, /**< this argument
350350
if (!ecma_is_value_object (this_arg)
351351
|| ecma_object_get_class_name (ecma_get_object_from_value (this_arg)) != LIT_MAGIC_STRING_DATE_UL)
352352
{
353-
ret_value = ecma_raise_type_error ("Incompatible type");
353+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incompatible type"));
354354
}
355355
else
356356
{
@@ -1146,7 +1146,7 @@ ecma_builtin_date_prototype_to_iso_string (ecma_value_t this_arg) /**< this argu
11461146

11471147
if (ecma_number_is_nan (*prim_num_p) || ecma_number_is_infinity (*prim_num_p))
11481148
{
1149-
ret_value = ecma_raise_range_error ("");
1149+
ret_value = ecma_raise_range_error (ECMA_ERR_MSG (""));
11501150
}
11511151
else
11521152
{
@@ -1207,7 +1207,7 @@ ecma_builtin_date_prototype_to_json (ecma_value_t this_arg, /**< this argument *
12071207
/* 5. */
12081208
if (!ecma_op_is_callable (to_iso))
12091209
{
1210-
ret_value = ecma_raise_type_error ("");
1210+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
12111211
}
12121212
/* 6. */
12131213
else

jerry-core/ecma/builtin-objects/ecma-builtin-date.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ ecma_builtin_date_now (ecma_value_t this_arg __attr_unused___) /**< this argumen
461461

462462
if (gettimeofday (&tv, NULL) != 0)
463463
{
464-
return ecma_raise_type_error ("gettimeofday failed");
464+
return ecma_raise_type_error (ECMA_ERR_MSG ("gettimeofday failed"));
465465
}
466466

467467
*now_num_p = ((ecma_number_t) tv.tv_sec) * 1000.0 + ((ecma_number_t) (tv.tv_usec / 1000));

jerry-core/ecma/builtin-objects/ecma-builtin-error-prototype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
6262
// 2.
6363
if (!ecma_is_value_object (this_arg))
6464
{
65-
ret_value = ecma_raise_type_error ("");
65+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
6666
}
6767
else
6868
{

jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ecma_builtin_function_prototype_object_to_string (ecma_value_t this_arg) /**< th
6060

6161
if (!ecma_op_is_callable (this_arg))
6262
{
63-
ret_value = ecma_raise_type_error ("");
63+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
6464
}
6565
else
6666
{
@@ -89,7 +89,7 @@ ecma_builtin_function_prototype_object_apply (ecma_value_t this_arg, /**< this a
8989
/* 1. */
9090
if (!ecma_op_is_callable (this_arg))
9191
{
92-
ret_value = ecma_raise_type_error ("");
92+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
9393
}
9494
else
9595
{
@@ -105,7 +105,7 @@ ecma_builtin_function_prototype_object_apply (ecma_value_t this_arg, /**< this a
105105
/* 3. */
106106
if (!ecma_is_value_object (arg2))
107107
{
108-
ret_value = ecma_raise_type_error ("");
108+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
109109
}
110110
else
111111
{
@@ -188,7 +188,7 @@ ecma_builtin_function_prototype_object_call (ecma_value_t this_arg, /**< this ar
188188
{
189189
if (!ecma_op_is_callable (this_arg))
190190
{
191-
return ecma_raise_type_error ("");
191+
return ecma_raise_type_error (ECMA_ERR_MSG (""));
192192
}
193193
else
194194
{
@@ -231,7 +231,7 @@ ecma_builtin_function_prototype_object_bind (ecma_value_t this_arg, /**< this ar
231231
/* 2. */
232232
if (!ecma_op_is_callable (this_arg))
233233
{
234-
ret_value = ecma_raise_type_error ("");
234+
ret_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
235235
}
236236
else
237237
{
@@ -392,7 +392,7 @@ ecma_builtin_function_prototype_dispatch_construct (const ecma_value_t *argument
392392
{
393393
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
394394

395-
return ecma_raise_type_error ("");
395+
return ecma_raise_type_error (ECMA_ERR_MSG (""));
396396
} /* ecma_builtin_function_prototype_dispatch_construct */
397397

398398
/**

jerry-core/ecma/builtin-objects/ecma-builtin-global.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ ecma_builtin_global_object_decode_uri_helper (ecma_value_t uri __attr_unused___,
805805

806806
if (!lit_read_code_point_from_hex (input_char_p + 1, 2, &decoded_byte))
807807
{
808-
ret_value = ecma_raise_uri_error ("");
808+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
809809
break;
810810
}
811811

@@ -861,7 +861,7 @@ ecma_builtin_global_object_decode_uri_helper (ecma_value_t uri __attr_unused___,
861861

862862
if (!lit_read_code_point_from_hex (input_char_p + 1, 2, &decoded_byte))
863863
{
864-
ret_value = ecma_raise_uri_error ("");
864+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
865865
break;
866866
}
867867

@@ -899,7 +899,7 @@ ecma_builtin_global_object_decode_uri_helper (ecma_value_t uri __attr_unused___,
899899
}
900900
else
901901
{
902-
ret_value = ecma_raise_uri_error ("");
902+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
903903
break;
904904
}
905905

@@ -933,7 +933,7 @@ ecma_builtin_global_object_decode_uri_helper (ecma_value_t uri __attr_unused___,
933933
if (!is_valid
934934
|| !lit_is_utf8_string_valid (octets, bytes_count))
935935
{
936-
ret_value = ecma_raise_uri_error ("");
936+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
937937
break;
938938
}
939939

@@ -943,7 +943,7 @@ ecma_builtin_global_object_decode_uri_helper (ecma_value_t uri __attr_unused___,
943943
if (lit_is_code_point_utf16_high_surrogate (cp)
944944
|| lit_is_code_point_utf16_low_surrogate (cp))
945945
{
946-
ret_value = ecma_raise_uri_error ("");
946+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
947947
break;
948948
}
949949

@@ -962,7 +962,7 @@ ecma_builtin_global_object_decode_uri_helper (ecma_value_t uri __attr_unused___,
962962
}
963963
else
964964
{
965-
ret_value = ecma_raise_uri_error ("");
965+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
966966
}
967967
}
968968

@@ -1074,7 +1074,7 @@ ecma_builtin_global_object_encode_uri_helper (ecma_value_t uri, /**< uri argumen
10741074

10751075
if (lit_is_code_point_utf16_low_surrogate (ch))
10761076
{
1077-
ret_value = ecma_raise_uri_error ("");
1077+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
10781078
break;
10791079
}
10801080

@@ -1084,7 +1084,7 @@ ecma_builtin_global_object_encode_uri_helper (ecma_value_t uri, /**< uri argumen
10841084
{
10851085
if (input_char_p == input_end_p)
10861086
{
1087-
ret_value = ecma_raise_uri_error ("");
1087+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
10881088
break;
10891089
}
10901090

@@ -1098,7 +1098,7 @@ ecma_builtin_global_object_encode_uri_helper (ecma_value_t uri, /**< uri argumen
10981098
}
10991099
else
11001100
{
1101-
ret_value = ecma_raise_uri_error ("");
1101+
ret_value = ecma_raise_uri_error (ECMA_ERR_MSG (""));
11021102
break;
11031103
}
11041104
}

0 commit comments

Comments
 (0)