зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1435483
part 21. Remove nsIException::ToString. r=qdot
MozReview-Commit-ID: 17yuhlqzbr2
This commit is contained in:
Родитель
d023fa0839
Коммит
4f2bf4184c
|
@ -256,7 +256,7 @@ Exception::GetFilename(JSContext* aCx, nsAString& aFilename)
|
|||
aFilename.Truncate();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
Exception::ToString(JSContext* aCx, nsACString& _retval)
|
||||
{
|
||||
static const char defaultMsg[] = "<no message>";
|
||||
|
@ -291,7 +291,6 @@ Exception::ToString(JSContext* aCx, nsACString& _retval)
|
|||
_retval.Truncate();
|
||||
_retval.AppendPrintf(format, msg, static_cast<uint32_t>(mResult), resultName,
|
||||
location.get(), data);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
|
@ -353,11 +352,7 @@ void
|
|||
Exception::Stringify(JSContext* aCx, nsString& retval)
|
||||
{
|
||||
nsCString str;
|
||||
#ifdef DEBUG
|
||||
DebugOnly<nsresult> rv =
|
||||
#endif
|
||||
ToString(aCx, str);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv));
|
||||
CopyUTF8toUTF16(str, retval);
|
||||
}
|
||||
|
||||
|
@ -392,7 +387,7 @@ DOMException::GetCode(uint16_t* aCode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
void
|
||||
DOMException::ToString(JSContext* aCx, nsACString& aReturn)
|
||||
{
|
||||
aReturn.Truncate();
|
||||
|
@ -414,8 +409,6 @@ DOMException::ToString(JSContext* aCx, nsACString& aReturn)
|
|||
|
||||
aReturn.AppendPrintf(format, msg, mCode, static_cast<uint32_t>(mResult), resultName,
|
||||
location.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -61,6 +61,9 @@ public:
|
|||
{
|
||||
return mResult;
|
||||
}
|
||||
// DOMException wants different ToString behavior, so allow it to override.
|
||||
virtual void ToString(JSContext* aCx, nsACString& aReturn);
|
||||
|
||||
|
||||
// Cruft used by XPConnect for exceptions originating in JS implemented
|
||||
// components.
|
||||
|
@ -151,9 +154,6 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIDOMDOMEXCEPTION
|
||||
|
||||
// nsIException overrides
|
||||
NS_IMETHOD ToString(JSContext* aCx, nsACString& aReturn) override;
|
||||
|
||||
// nsWrapperCache overrides
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
override;
|
||||
|
@ -171,6 +171,9 @@ public:
|
|||
// Intentionally shadow the Exception version.
|
||||
void GetName(nsString& retval);
|
||||
|
||||
// Exception overrides
|
||||
void ToString(JSContext* aCx, nsACString& aReturn) override;
|
||||
|
||||
virtual void GetErrorMessage(nsAString& aRetVal) override
|
||||
{
|
||||
// See the comment in Exception::GetErrorMessage.
|
||||
|
|
|
@ -956,8 +956,8 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
|||
fputs(line, stdout);
|
||||
fputs(preamble, stdout);
|
||||
nsCString text;
|
||||
if (NS_SUCCEEDED(xpc_exception->ToString(cx, text)) &&
|
||||
!text.IsEmpty()) {
|
||||
xpc_exception->ToString(cx, text);
|
||||
if (!text.IsEmpty()) {
|
||||
fputs(text.get(), stdout);
|
||||
fputs("\n", stdout);
|
||||
} else
|
||||
|
@ -970,7 +970,6 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
|||
nsCOMPtr<nsIConsoleService> consoleService
|
||||
(do_GetService(XPC_CONSOLE_CONTRACTID));
|
||||
if (nullptr != consoleService) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIScriptError> scriptError =
|
||||
do_QueryInterface(xpc_exception->GetData());
|
||||
|
||||
|
@ -980,32 +979,31 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
|
|||
scriptError = do_CreateInstance(XPC_SCRIPT_ERROR_CONTRACTID);
|
||||
if (nullptr != scriptError) {
|
||||
nsCString newMessage;
|
||||
rv = xpc_exception->ToString(cx, newMessage);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// try to get filename, lineno from the first
|
||||
// stack frame location.
|
||||
int32_t lineNumber = 0;
|
||||
nsString sourceName;
|
||||
xpc_exception->ToString(cx, newMessage);
|
||||
// try to get filename, lineno from the first
|
||||
// stack frame location.
|
||||
int32_t lineNumber = 0;
|
||||
nsString sourceName;
|
||||
|
||||
nsCOMPtr<nsIStackFrame> location =
|
||||
xpc_exception->GetLocation();
|
||||
if (location) {
|
||||
// Get line number.
|
||||
lineNumber = location->GetLineNumber(cx);
|
||||
nsCOMPtr<nsIStackFrame> location =
|
||||
xpc_exception->GetLocation();
|
||||
if (location) {
|
||||
// Get line number.
|
||||
lineNumber = location->GetLineNumber(cx);
|
||||
|
||||
// get a filename.
|
||||
location->GetFilename(cx, sourceName);
|
||||
}
|
||||
|
||||
rv = scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(newMessage),
|
||||
sourceName,
|
||||
EmptyString(),
|
||||
lineNumber, 0, 0,
|
||||
"XPConnect JavaScript",
|
||||
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
|
||||
if (NS_FAILED(rv))
|
||||
scriptError = nullptr;
|
||||
// get a filename.
|
||||
location->GetFilename(cx, sourceName);
|
||||
}
|
||||
|
||||
nsresult rv =
|
||||
scriptError->InitWithWindowID(NS_ConvertUTF8toUTF16(newMessage),
|
||||
sourceName,
|
||||
EmptyString(),
|
||||
lineNumber, 0, 0,
|
||||
"XPConnect JavaScript",
|
||||
nsJSUtils::GetCurrentlyRunningCodeInnerWindowID(cx));
|
||||
if (NS_FAILED(rv))
|
||||
scriptError = nullptr;
|
||||
}
|
||||
}
|
||||
if (nullptr != scriptError)
|
||||
|
|
|
@ -65,10 +65,11 @@ interface nsIStackFrame : nsISupports
|
|||
void toStringInfallible(in JSContext aCx, out AUTF8String aString);
|
||||
};
|
||||
|
||||
// This interface only exists because of all the JS consumers doing
|
||||
// "instanceof Ci.nsIException". We should switch them to something else and
|
||||
// get rid of it; bug 1435856 tracks that. C++ code should NOT use this; use
|
||||
// mozilla::dom::Exception instead.
|
||||
[scriptable, builtinclass, uuid(4371b5bf-6845-487f-8d9d-3f1e4a9badd2)]
|
||||
interface nsIException : nsISupports
|
||||
{
|
||||
// A generic formatter - make it suitable to print, etc.
|
||||
[implicit_jscontext]
|
||||
AUTF8String toString();
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче