Bug 1229664. Drop the concept of inner exceptions from Exception/DOMException. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 02 Dec 2015 13:52:59 -0500
changeset 309443 932fcd51eacef36cc2b568d719f830f3f7b5b2c7
parent 309442 87d9fe68abf24bd062bc8ef140c3fed161ec6182
child 309444 5f84bb42a723a215da4308794cfdf09e0cdb4973
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1229664
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1229664. Drop the concept of inner exceptions from Exception/DOMException. r=bholley
dom/base/DOMException.cpp
dom/base/DOMException.h
dom/webidl/DOMException.webidl
js/xpconnect/idl/xpcexception.idl
xpcom/base/nsIException.idl
--- a/dom/base/DOMException.cpp
+++ b/dom/base/DOMException.cpp
@@ -172,28 +172,26 @@ NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(Exception)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(Exception)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(Exception)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(Exception)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mLocation)
-  NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInner)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(Exception)
   NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
   NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mThrownJSVal);
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(Exception)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mLocation)
-  NS_IMPL_CYCLE_COLLECTION_UNLINK(mInner)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
   tmp->mThrownJSVal.setNull();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_IMPL_CI_INTERFACE_GETTER(Exception, nsIXPCException)
 
 Exception::Exception(const nsACString& aMessage,
                      nsresult aResult,
@@ -243,17 +241,17 @@ Exception::Exception(const nsACString& a
       nsCOMPtr<nsIStackFrame> caller;
       if (NS_FAILED(location->GetCaller(getter_AddRefs(caller))) || !caller) {
         break;
       }
       location = caller;
     }
   }
 
-  Initialize(aMessage, aResult, aName, location, aData, nullptr);
+  Initialize(aMessage, aResult, aName, location, aData);
 }
 
 Exception::Exception()
   : mResult(NS_OK),
     mLineNumber(-1),
     mInitialized(false),
     mHoldingJSVal(false)
 {
@@ -395,27 +393,16 @@ Exception::GetData(nsISupports** aData)
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   nsCOMPtr<nsISupports> data = mData;
   data.forget(aData);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-Exception::GetInner(nsIException** aException)
-{
-  NS_ENSURE_ARG_POINTER(aException);
-  NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
-
-  nsCOMPtr<nsIException> inner = mInner;
-  inner.forget(aException);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 Exception::ToString(nsACString& _retval)
 {
   NS_ENSURE_TRUE(mInitialized, NS_ERROR_NOT_INITIALIZED);
 
   static const char defaultMsg[] = "<no message>";
   static const char defaultLocation[] = "<unknown>";
   static const char format[] =
 "[Exception... \"%s\"  nsresult: \"0x%x (%s)\"  location: \"%s\"  data: %s]";
@@ -449,17 +436,17 @@ Exception::ToString(nsACString& _retval)
   _retval.AppendPrintf(format, msg, mResult, resultName,
                        location.get(), data);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Exception::Initialize(const nsACString& aMessage, nsresult aResult,
                       const nsACString& aName, nsIStackFrame *aLocation,
-                      nsISupports *aData, nsIException *aInner)
+                      nsISupports *aData)
 {
   NS_ENSURE_FALSE(mInitialized, NS_ERROR_ALREADY_INITIALIZED);
 
   mMessage = aMessage;
   mName = aName;
   mResult = aResult;
 
   if (aLocation) {
@@ -469,17 +456,16 @@ Exception::Initialize(const nsACString& 
     nsXPConnect* xpc = nsXPConnect::XPConnect();
     rv = xpc->GetCurrentJSStack(getter_AddRefs(mLocation));
     if (NS_FAILED(rv)) {
       return rv;
     }
   }
 
   mData = aData;
-  mInner = aInner;
 
   mInitialized = true;
   return NS_OK;
 }
 
 JSObject*
 Exception::WrapObject(JSContext* cx, JS::Handle<JSObject*> aGivenProto)
 {
@@ -539,23 +525,16 @@ Exception::ColumnNumber() const
 already_AddRefed<nsIStackFrame>
 Exception::GetLocation() const
 {
   nsCOMPtr<nsIStackFrame> location = mLocation;
   return location.forget();
 }
 
 already_AddRefed<nsISupports>
-Exception::GetInner() const
-{
-  nsCOMPtr<nsIException> inner = mInner;
-  return inner.forget();
-}
-
-already_AddRefed<nsISupports>
 Exception::GetData() const
 {
   nsCOMPtr<nsISupports> data = mData;
   return data.forget();
 }
 
 void
 Exception::GetStack(nsAString& aStack, ErrorResult& aRv) const
@@ -618,35 +597,16 @@ DOMException::ToString(nsACString& aRetu
   static const char defaultMsg[] = "<no message>";
   static const char defaultLocation[] = "<unknown>";
   static const char defaultName[] = "<unknown>";
   static const char format[] =
     "[Exception... \"%s\"  code: \"%d\" nsresult: \"0x%x (%s)\"  location: \"%s\"]";
 
   nsAutoCString location;
 
-  if (mInner) {
-    nsString filename;
-    mInner->GetFilename(filename);
-
-    if (!filename.IsEmpty()) {
-      uint32_t line_nr = 0;
-
-      mInner->GetLineNumber(&line_nr);
-
-      char *temp = PR_smprintf("%s Line: %d",
-                               NS_ConvertUTF16toUTF8(filename).get(),
-                               line_nr);
-      if (temp) {
-        location.Assign(temp);
-        PR_smprintf_free(temp);
-      }
-    }
-  }
-
   if (location.IsEmpty()) {
     location = defaultLocation;
   }
 
   const char* msg = !mMessage.IsEmpty() ? mMessage.get() : defaultMsg;
   const char* resultName = !mName.IsEmpty() ? mName.get() : defaultName;
 
   aReturn.AppendPrintf(format, msg, mCode, mResult, resultName,
--- a/dom/base/DOMException.h
+++ b/dom/base/DOMException.h
@@ -79,18 +79,16 @@ public:
   // return an empty filename in that case anyway, instead of throwing.
 
   uint32_t LineNumber() const;
 
   uint32_t ColumnNumber() const;
 
   already_AddRefed<nsIStackFrame> GetLocation() const;
 
-  already_AddRefed<nsISupports> GetInner() const;
-
   already_AddRefed<nsISupports> GetData() const;
 
   void GetStack(nsAString& aStack, ErrorResult& aRv) const;
 
   void Stringify(nsString& retval);
 
   // XPCOM factory ctor.
   Exception();
@@ -106,17 +104,16 @@ protected:
 
   nsCString       mMessage;
   nsresult        mResult;
   nsCString       mName;
   nsCOMPtr<nsIStackFrame> mLocation;
   nsCOMPtr<nsISupports> mData;
   nsString        mFilename;
   int             mLineNumber;
-  nsCOMPtr<nsIException> mInner;
   bool            mInitialized;
 
   bool mHoldingJSVal;
   JS::Heap<JS::Value> mThrownJSVal;
 
 private:
   static bool sEverMadeOneFromFactory;
 };
--- a/dom/webidl/DOMException.webidl
+++ b/dom/webidl/DOMException.webidl
@@ -47,18 +47,16 @@ interface ExceptionMembers
   // Valid column numbers begin at 0. 
   // We don't have an unambiguous indicator for unknown.
   readonly attribute unsigned long           columnNumber;
 
   // A stack trace, if available.  nsIStackFrame does not have classinfo so
   // this was only ever usefully available to chrome JS.
   [ChromeOnly, Exposed=Window]
   readonly attribute StackFrame?             location;
-  // An inner exception that triggered this, if available.
-  readonly attribute nsISupports?            inner;
 
   // Arbitary data for the implementation.
   [Exposed=Window]
   readonly attribute nsISupports?            data;
 
   // Formatted exception stack
   [Throws, Replaceable]
   readonly attribute DOMString               stack;
--- a/js/xpconnect/idl/xpcexception.idl
+++ b/js/xpconnect/idl/xpcexception.idl
@@ -2,27 +2,26 @@
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIException.idl"
 
-[scriptable, uuid(dd250248-2586-4ec1-a68f-8d14ef452517)]
+[scriptable, uuid(875e6645-e762-4da6-9ec8-bf19ab0050df)]
 interface nsIXPCException : nsIException
 {
     // inherits methods from nsIException
 
     void initialize(in AUTF8String      aMessage,
                     in nsresult         aResult,
                     in AUTF8String      aName,
                     in nsIStackFrame    aLocation,
-                    in nsISupports      aData,
-                    in nsIException     aInner);
+                    in nsISupports      aData);
 };
 
 /* this goes into the C++ header verbatim. */
 %{ C++
 /********************************************************/
 // {5632BF70-51EC-11d3-9896-006008962422}
 #define NS_XPCEXCEPTION_CID  \
 { 0x5632bf70, 0x51ec, 0x11d3, \
--- a/xpcom/base/nsIException.idl
+++ b/xpcom/base/nsIException.idl
@@ -33,17 +33,17 @@ interface nsIStackFrame : nsISupports
 
     // Returns the underlying SavedFrame object for native JavaScript stacks,
     // or null if this is not a native JavaScript stack frame.
     readonly attribute jsval                   nativeSavedFrame;
 
     AUTF8String toString();
 };
 
-[scriptable, uuid(1caf1461-be1d-4b79-a552-5292b6bf3c35)]
+[scriptable, uuid(4371b5bf-6845-487f-8d9d-3f1e4a9badd2)]
 interface nsIException : nsISupports
 {
     // A custom message set by the thrower.
     [binaryname(MessageMoz)] readonly attribute AUTF8String message;
     // The nsresult associated with this exception.
     readonly attribute nsresult                result;
     // The name of the error code (ie, a string repr of |result|)
     readonly attribute AUTF8String             name;
@@ -60,17 +60,15 @@ interface nsIException : nsISupports
     // Valid line numbers begin at '1'. '0' indicates unknown.
     readonly attribute uint32_t                lineNumber;
     // Valid column numbers begin at 0.
     // We don't have an unambiguous indicator for unknown.
     readonly attribute uint32_t                columnNumber;
 
     // A stack trace, if available.
     readonly attribute nsIStackFrame           location;
-    // An inner exception that triggered this, if available.
-    readonly attribute nsIException            inner;
 
     // Arbitary data for the implementation.
     readonly attribute nsISupports             data;
 
     // A generic formatter - make it suitable to print, etc.
     AUTF8String toString();
 };