From f6ee5e4ad2cde2b6968341cafbcb8179fbddc39f Mon Sep 17 00:00:00 2001 From: "Pedram (pebr)" Date: Wed, 6 Mar 2024 13:30:44 +0100 Subject: [PATCH] [FIX] point_of_sale: correctly handle RPCError Prior to this commit, in the event of an RPCError, such as UserError or ValidationError, it would display a generic 'Odoo Server Error' error. This error lacked useful information for diagnosing and addressing the issue. opw-3776047 closes odoo/odoo#156697 Signed-off-by: Joseph Caburnay (jcb) --- .../static/src/app/errors/error_handlers.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/point_of_sale/static/src/app/errors/error_handlers.js b/addons/point_of_sale/static/src/app/errors/error_handlers.js index f42c363b316..887ab858789 100644 --- a/addons/point_of_sale/static/src/app/errors/error_handlers.js +++ b/addons/point_of_sale/static/src/app/errors/error_handlers.js @@ -9,10 +9,11 @@ import { OfflineErrorPopup } from "@point_of_sale/app/errors/popups/offline_erro import { _t } from "@web/core/l10n/translation"; function rpcErrorHandler(env, error, originalError) { - if (error instanceof RPCError) { - const { message, data } = error; - if (odooExceptionTitleMap.has(error.exceptionName)) { - const title = odooExceptionTitleMap.get(error.exceptionName).toString(); + const rpcError = error instanceof RPCError ? error : (originalError instanceof RPCError ? originalError : null); + if (rpcError) { + const { message, data } = rpcError; + if (odooExceptionTitleMap.has(rpcError.exceptionName)) { + const title = odooExceptionTitleMap.get(rpcError.exceptionName).toString(); env.services.popup.add(ErrorPopup, { title, body: data.message }); } else { env.services.popup.add(ErrorTracebackPopup, {