1/* Copyright JS Foundation and other contributors, http://js.foundation 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#ifndef ECMA_EXCEPTIONS_H 17#define ECMA_EXCEPTIONS_H 18 19#include "ecma-globals.h" 20#include "jrt.h" 21 22/** \addtogroup ecma ECMA 23 * @{ 24 * 25 * \addtogroup exceptions Exceptions 26 * @{ 27 */ 28 29#if ENABLED (JERRY_ERROR_MESSAGES) 30#define ECMA_ERR_MSG(msg) msg 31#else /* !ENABLED (JERRY_ERROR_MESSAGES) */ 32#define ECMA_ERR_MSG(msg) NULL 33#endif /* ENABLED (JERRY_ERROR_MESSAGES) */ 34 35/** 36 * Native errors. 37 * 38 * See also: 15.11.1, 15.11.6 39 */ 40typedef enum 41{ 42 ECMA_ERROR_NONE, /**< Not an Error */ 43 44 ECMA_ERROR_COMMON, /**< Error */ 45 ECMA_ERROR_EVAL, /**< EvalError */ 46 ECMA_ERROR_RANGE, /**< RangeError */ 47 ECMA_ERROR_REFERENCE, /**< ReferenceError */ 48 ECMA_ERROR_SYNTAX, /**< SyntaxError */ 49 ECMA_ERROR_TYPE, /**< TypeError */ 50 ECMA_ERROR_URI /**< URIError */ 51} ecma_standard_error_t; 52 53ecma_standard_error_t ecma_get_error_type (ecma_object_t *error_object); 54ecma_object_t *ecma_new_standard_error (ecma_standard_error_t error_type); 55ecma_object_t *ecma_new_standard_error_with_message (ecma_standard_error_t error_type, ecma_string_t *message_string_p); 56#if ENABLED (JERRY_ERROR_MESSAGES) 57ecma_value_t ecma_raise_standard_error_with_format (ecma_standard_error_t error_type, const char *msg_p, ...); 58#endif /* ENABLED (JERRY_ERROR_MESSAGES) */ 59ecma_value_t ecma_raise_common_error (const char *msg_p); 60ecma_value_t ecma_raise_range_error (const char *msg_p); 61ecma_value_t ecma_raise_reference_error (const char *msg_p); 62ecma_value_t ecma_raise_syntax_error (const char *msg_p); 63ecma_value_t ecma_raise_type_error (const char *msg_p); 64ecma_value_t ecma_raise_uri_error (const char *msg_p); 65 66/** 67 * @} 68 * @} 69 */ 70 71#endif /* !ECMA_EXCEPTIONS_H */ 72