[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) <jcb@odoo.com>
This commit is contained in:
Pedram (pebr)
2024-03-06 14:30:47 +00:00
parent 9626504181
commit f6ee5e4ad2
@@ -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, {