From 19217ce64bd0e29bfa61d34788bb103e86715d5a Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Thu, 7 Sep 2023 15:16:54 +0200 Subject: [PATCH] [FIX] web: restore legacy rpc error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- addons/web/static/src/legacy/utils.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/legacy/utils.js b/addons/web/static/src/legacy/utils.js index 8dd659be439..bdff1ea1dc6 100644 --- a/addons/web/static/src/legacy/utils.js +++ b/addons/web/static/src/legacy/utils.js @@ -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); + } } }); });