JavaScriptCore/runtime/Error.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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     JSObject* addErrorInfo(JSGlobalData*, JSObject* error, int line, const SourceCode&, int divotPoint, int startOffset, int endOffset, bool withCaret = true);
       
    60     // ExecState wrappers.
       
    61     JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&);
       
    62     JSObject* addErrorInfo(ExecState*, JSObject* error, int line, const SourceCode&, int divotPoint, int startOffset, int endOffset, bool withCaret = true);
       
    63 
       
    64     // Methods to throw Errors.
       
    65     JSValue throwError(ExecState*, JSValue);
       
    66     JSObject* throwError(ExecState*, JSObject*);
       
    67 
       
    68     // Convenience wrappers, create an throw an exception with a default message.
       
    69     JSObject* throwTypeError(ExecState*);
       
    70     JSObject* throwSyntaxError(ExecState*);
       
    71 
       
    72     // Convenience wrappers, wrap result as an EncodedJSValue.
       
    73     inline EncodedJSValue throwVMError(ExecState* exec, JSValue error) { return JSValue::encode(throwError(exec, error)); }
       
    74     inline EncodedJSValue throwVMTypeError(ExecState* exec) { return JSValue::encode(throwTypeError(exec)); }
       
    75 
       
    76 } // namespace JSC
       
    77 
       
    78 #endif // Error_h