Bug 1680377 - Follow-up fixes to WebGPU error scope

addressing post-landing review notes of
https://phabricator.services.mozilla.com/D118741

Differential Revision: https://phabricator.services.mozilla.com/D119654
This commit is contained in:
Dzmitry Malyshau 2021-07-13 01:26:46 +00:00
Родитель 7f684896cb
Коммит 504ad98a7b
2 изменённых файлов: 10 добавлений и 9 удалений

Просмотреть файл

@ -35,11 +35,13 @@ class ErrorBuffer {
return errorBuf;
}
bool CheckError() {
Maybe<nsCString> GetError() {
mGuard = false;
return mUtf8[0] != 0;
if (!mUtf8[0]) {
return Nothing();
}
return Some(nsCString(mUtf8));
}
nsDependentCString GetError() const { return nsDependentCString(mUtf8); };
};
class PresentationData {
@ -207,22 +209,21 @@ void WebGPUParent::MaintainDevices() {
bool WebGPUParent::ForwardError(RawId aDeviceId, ErrorBuffer& aError) {
// don't do anything if the error is empty
if (!aError.CheckError()) {
auto cString = aError.GetError();
if (!cString) {
return false;
}
auto cString = aError.GetError();
// find the appropriate error scope
const auto& lookup = mErrorScopeMap.find(aDeviceId);
if (lookup != mErrorScopeMap.end() && !lookup->second.mStack.IsEmpty()) {
auto& last = lookup->second.mStack.LastElement();
if (last.isNothing()) {
last.emplace(ScopedError{false, std::move(cString)});
last.emplace(ScopedError{false, cString.value()});
}
} else {
// fall back to the uncaptured error handler
if (!SendDeviceUncapturedError(aDeviceId, cString)) {
if (!SendDeviceUncapturedError(aDeviceId, cString.value())) {
NS_ERROR("Unable to SendError");
}
}

Просмотреть файл

@ -24,7 +24,7 @@ const func = async function() {
await device.popErrorScope();
ok(false, "Should have thrown")
} catch (ex) {
ok(ex instanceof OperationError, "Should throw an OperationError")
ok(ex.name == 'OperationError', "Should throw an OperationError")
}
};