michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_DOMException_h__ michael@0: #define mozilla_dom_DOMException_h__ michael@0: michael@0: // We intentionally shadow non-virtual methods, but gcc gets confused. michael@0: #ifdef __GNUC__ michael@0: #pragma GCC diagnostic push michael@0: #pragma GCC diagnostic ignored "-Woverloaded-virtual" michael@0: #endif michael@0: michael@0: #include michael@0: #include "jspubtd.h" michael@0: #include "js/GCAPI.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsID.h" michael@0: #include "nsIDOMDOMException.h" michael@0: #include "nsWrapperCache.h" michael@0: #include "xpcexception.h" michael@0: #include "nsString.h" michael@0: michael@0: class nsIStackFrame; michael@0: class nsString; michael@0: michael@0: nsresult michael@0: NS_GetNameAndMessageForDOMNSResult(nsresult aNSResult, nsACString& aName, michael@0: nsACString& aMessage, michael@0: uint16_t* aCode = nullptr); michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: #define MOZILLA_EXCEPTION_IID \ michael@0: { 0x55eda557, 0xeba0, 0x4fe3, \ michael@0: { 0xae, 0x2e, 0xf3, 0x94, 0x49, 0x23, 0x62, 0xd6 } } michael@0: michael@0: class Exception : public nsIXPCException, michael@0: public nsWrapperCache michael@0: { michael@0: public: michael@0: NS_DECLARE_STATIC_IID_ACCESSOR(MOZILLA_EXCEPTION_IID) michael@0: michael@0: NS_DEFINE_STATIC_CID_ACCESSOR(NS_XPCEXCEPTION_CID) michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Exception) michael@0: michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_NSIEXCEPTION michael@0: NS_DECL_NSIXPCEXCEPTION michael@0: michael@0: // Cruft used by XPConnect for exceptions originating in JS implemented michael@0: // components. michael@0: bool StealJSVal(JS::Value* aVp); michael@0: void StowJSVal(JS::Value& aVp); michael@0: michael@0: // WebIDL API michael@0: virtual JSObject* WrapObject(JSContext* cx) michael@0: MOZ_OVERRIDE; michael@0: michael@0: nsISupports* GetParentObject() const { return nullptr; } michael@0: michael@0: void GetMessageMoz(nsString& retval); michael@0: michael@0: uint32_t Result() const; michael@0: michael@0: void GetName(nsString& retval); michael@0: michael@0: // The XPCOM GetFilename does the right thing. michael@0: michael@0: uint32_t LineNumber() const; michael@0: michael@0: uint32_t ColumnNumber() const; michael@0: michael@0: already_AddRefed GetLocation() const; michael@0: michael@0: already_AddRefed GetInner() const; michael@0: michael@0: already_AddRefed GetData() const; michael@0: michael@0: void Stringify(nsString& retval); michael@0: michael@0: // XPCOM factory ctor. michael@0: Exception(); michael@0: michael@0: Exception(const nsACString& aMessage, michael@0: nsresult aResult, michael@0: const nsACString& aName, michael@0: nsIStackFrame *aLocation, michael@0: nsISupports *aData); michael@0: michael@0: protected: michael@0: virtual ~Exception(); michael@0: michael@0: nsCString mMessage; michael@0: nsresult mResult; michael@0: nsCString mName; michael@0: nsCOMPtr mLocation; michael@0: nsCOMPtr mData; michael@0: nsString mFilename; michael@0: int mLineNumber; michael@0: nsCOMPtr mInner; michael@0: bool mInitialized; michael@0: michael@0: bool mHoldingJSVal; michael@0: JS::Heap mThrownJSVal; michael@0: michael@0: private: michael@0: static bool sEverMadeOneFromFactory; michael@0: }; michael@0: michael@0: NS_DEFINE_STATIC_IID_ACCESSOR(Exception, MOZILLA_EXCEPTION_IID) michael@0: michael@0: class DOMException : public Exception, michael@0: public nsIDOMDOMException michael@0: { michael@0: public: michael@0: DOMException(nsresult aRv, const nsACString& aMessage, michael@0: const nsACString& aName, uint16_t aCode); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_NSIDOMDOMEXCEPTION michael@0: michael@0: // nsIException overrides michael@0: NS_IMETHOD ToString(nsACString& aReturn) MOZ_OVERRIDE; michael@0: michael@0: // nsWrapperCache overrides michael@0: virtual JSObject* WrapObject(JSContext* aCx) michael@0: MOZ_OVERRIDE; michael@0: michael@0: uint16_t Code() const { michael@0: return mCode; michael@0: } michael@0: michael@0: // Intentionally shadow the nsXPCException version. michael@0: void GetMessageMoz(nsString& retval); michael@0: void GetName(nsString& retval); michael@0: michael@0: static already_AddRefed michael@0: Create(nsresult aRv); michael@0: michael@0: protected: michael@0: michael@0: virtual ~DOMException() {} michael@0: michael@0: nsCString mName; michael@0: nsCString mMessage; michael@0: michael@0: uint16_t mCode; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #ifdef __GNUC__ michael@0: #pragma GCC diagnostic pop michael@0: #endif michael@0: michael@0: #endif