mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1157754 part 1. Add a way to "catch" an ErrorResult, and a way to safely convert an ErrorResult to an nsresult. r=peterv
This commit is contained in:
parent
19d0a09a5f
commit
399ba482a5
@ -378,6 +378,24 @@ ErrorResult::operator=(ErrorResult&& aRHS)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void
|
||||
ErrorResult::SuppressException()
|
||||
{
|
||||
WouldReportJSException();
|
||||
if (IsErrorWithMessage()) {
|
||||
ClearMessage();
|
||||
} else if (IsJSException()) {
|
||||
JSContext* cx = nsContentUtils::GetDefaultJSContextForThread();
|
||||
// Just steal it into a stack value (unrooting it in the process)
|
||||
// that we then allow to die.
|
||||
JS::Rooted<JS::Value> temp(cx);
|
||||
StealJSException(cx, &temp);
|
||||
}
|
||||
// We don't use AssignErrorCode, because we want to override existing error
|
||||
// states, which AssignErrorCode is not allowed to do.
|
||||
mResult = NS_OK;
|
||||
}
|
||||
|
||||
namespace dom {
|
||||
|
||||
bool
|
||||
|
@ -77,6 +77,20 @@ public:
|
||||
AssignErrorCode(rv);
|
||||
}
|
||||
|
||||
// Use SuppressException when you want to suppress any exception that might be
|
||||
// on the ErrorResult. After this call, the ErrorResult will be back a "no
|
||||
// exception thrown" state.
|
||||
void SuppressException();
|
||||
|
||||
// Use StealNSResult() when you want to safely convert the ErrorResult to an
|
||||
// nsresult that you will then return to a caller. This will
|
||||
// SuppressException(), since there will no longer be a way to report it.
|
||||
nsresult StealNSResult() {
|
||||
nsresult rv = ErrorCode();
|
||||
SuppressException();
|
||||
return rv;
|
||||
}
|
||||
|
||||
void ThrowTypeError(const dom::ErrNum errorNumber, ...);
|
||||
void ThrowRangeError(const dom::ErrNum errorNumber, ...);
|
||||
void ReportErrorWithMessage(JSContext* cx);
|
||||
|
Loading…
Reference in New Issue
Block a user