1 /* 2 * Copyright (C) 1999-2001 Harri Porten (porten@kde.org) 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public License 17 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef Error_h 24 #define Error_h 25 26 #include "JSObject.h" 27 #include <stdint.h> 28 29 namespace JSC { 30 31 class ExecState; 32 class JSGlobalData; 33 class JSGlobalObject; 34 class JSObject; 35 class SourceCode; 36 class Structure; 37 class UString; 38 39 // Methods to create a range of internal errors. 40 JSObject* createError(JSGlobalObject*, const UString&); 41 JSObject* createEvalError(JSGlobalObject*, const UString&); 42 JSObject* createRangeError(JSGlobalObject*, const UString&); 43 JSObject* createReferenceError(JSGlobalObject*, const UString&); 44 JSObject* createSyntaxError(JSGlobalObject*, const UString&); 45 JSObject* createTypeError(JSGlobalObject*, const UString&); 46 JSObject* createURIError(JSGlobalObject*, const UString&); 47 // ExecState wrappers. 48 JSObject* createError(ExecState*, const UString&); 49 JSObject* createEvalError(ExecState*, const UString&); 50 JSObject* createRangeError(ExecState*, const UString&); 51 JSObject* createReferenceError(ExecState*, const UString&); 52 JSObject* createSyntaxError(ExecState*, const UString&); 53 JSObject* createTypeError(ExecState*, const UString&); 54 JSObject* createURIError(ExecState*, const UString&); 55 56 // Methods to add 57 bool hasErrorInfo(ExecState*, JSObject* error); 58 JSObject* addErrorInfo(JSGlobalData*, JSObject* error, int line, const SourceCode&); 59 // ExecState wrappers. 60 JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&); 61 62 // Methods to throw Errors. 63 JSValue throwError(ExecState*, JSValue); 64 JSObject* throwError(ExecState*, JSObject*); 65 66 // Convenience wrappers, create an throw an exception with a default message. 67 JSObject* throwTypeError(ExecState*); 68 JSObject* throwSyntaxError(ExecState*); 69 70 // Convenience wrappers, wrap result as an EncodedJSValue. throwVMError(ExecState * exec,JSValue error)71 inline EncodedJSValue throwVMError(ExecState* exec, JSValue error) { return JSValue::encode(throwError(exec, error)); } throwVMTypeError(ExecState * exec)72 inline EncodedJSValue throwVMTypeError(ExecState* exec) { return JSValue::encode(throwTypeError(exec)); } 73 74 JSValue createTypeErrorFunction(ExecState* exec, const UString& message); 75 76 } // namespace JSC 77 78 #endif // Error_h 79