[FIX] web: restore legacy rpc error handling

Previously we removed some code related to handling errors in legacy
RPC, that would wrap errors in an object and give them an event that
could be defaultPrevented to mark the error as handled, but this code is
still needed. This commit restores it.

closes odoo/odoo#134693

Signed-off-by: Michaël Mattiello (mcm) <mcm@odoo.com>
This commit is contained in:
Samuel Degueldre
2023-09-07 14:45:30 +00:00
parent c2f9b87a03
commit 19217ce64b
+15 -2
View File
@@ -4,6 +4,11 @@ import { browser } from "../core/browser/browser";
import { useService } from "@web/core/utils/hooks";
import { Component, useComponent, xml } from "@odoo/owl";
import { loadJS } from "@web/core/assets";
import {
ConnectionAbortedError,
ConnectionLostError,
RPCError,
} from "@web/core/network/rpc_service";
export const wowlServicesSymbol = Symbol("wowlServices");
@@ -186,9 +191,17 @@ export function makeLegacyRPC(wowlRPC) {
resolve(result);
}
})
.guardedCatch(function (reason) {
.catch(function (reason) {
if (!target.isDestroyed()) {
reject(reason);
if (reason instanceof RPCError || reason instanceof ConnectionLostError) {
// we do not reject an error here because we want to pass through
// the legacy guardedCatch code
reject({ message: reason, event: $.Event(), legacy: true });
} else if (reason instanceof ConnectionAbortedError) {
reject({ message: reason.message, event: $.Event("abort") });
} else {
reject(reason);
}
}
});
});