[REF] point_of_sale: remove identifyError

After the the POS refactoring, there are no more errors
of type `legacy`, so the function `identifyError`, whose objective
was to identify the `legacy` errrors, is now completely useless.
We thus remove it.

closes odoo/odoo#136833

Task: 3524670
Signed-off-by: Robin Heinz (rhe) <rhe@odoo.com>
This commit is contained in:
vlst
2023-10-04 19:40:17 +00:00
parent 2fbc08a197
commit db565a3d8d
3 changed files with 2 additions and 15 deletions
@@ -8,12 +8,7 @@ import { ErrorTracebackPopup } from "@point_of_sale/app/errors/popups/error_trac
import { OfflineErrorPopup } from "@point_of_sale/app/errors/popups/offline_error_popup";
import { _t } from "@web/core/l10n/translation";
export function identifyError(error) {
return error && error.legacy ? error.message : error;
}
function rpcErrorHandler(env, error, originalError) {
error = identifyError(originalError);
if (error instanceof RPCError) {
const { message, data } = error;
if (odooExceptionTitleMap.has(error.exceptionName)) {
@@ -31,7 +26,6 @@ function rpcErrorHandler(env, error, originalError) {
registry.category("error_handlers").add("rpcErrorHandler", rpcErrorHandler);
function offlineErrorHandler(env, error, originalError) {
error = identifyError(originalError);
if (error instanceof ConnectionLostError) {
env.services.popup.add(OfflineErrorPopup);
return true;
@@ -40,7 +34,6 @@ function offlineErrorHandler(env, error, originalError) {
registry.category("error_handlers").add("offlineErrorHandler", offlineErrorHandler);
function defaultErrorHandler(env, error, originalError) {
originalError = identifyError(originalError);
if (error instanceof Error) {
env.services.popup.add(ErrorTracebackPopup, {
title: `${originalError.name}: ${originalError.message}`,
@@ -8,7 +8,6 @@ import { useService } from "@web/core/utils/hooks";
import { useState } from "@odoo/owl";
import { ErrorPopup } from "@point_of_sale/app/errors/popups/error_popup";
import { ConnectionLostError } from "@web/core/network/rpc_service";
import { identifyError } from "@point_of_sale/app/errors/error_handlers";
import { _t } from "@web/core/l10n/translation";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { parseFloat } from "@web/views/fields/parsers";
@@ -207,7 +206,7 @@ export class ClosePosPopup extends AbstractAwaitablePopup {
}
window.location = "/web#action=point_of_sale.action_client_pos_menu";
} catch (error) {
if (identifyError(error) instanceof ConnectionLostError) {
if (error instanceof ConnectionLostError) {
// Cannot redirect to backend when offline, let error handlers show the offline popup
// FIXME POSREF: doing this means closing again when online will redo the beginning of the method
// although it's impossible to close again because this.closeSessionClicked isn't reset to false
@@ -3,7 +3,6 @@
import { _t } from "@web/core/l10n/translation";
import { usePos } from "@point_of_sale/app/store/pos_hook";
import { useService } from "@web/core/utils/hooks";
import { identifyError } from "@point_of_sale/app/errors/error_handlers";
import { ConnectionLostError, ConnectionAbortedError } from "@web/core/network/rpc_service";
import { ProductCard } from "@point_of_sale/app/generic_components/product_card/product_card";
@@ -154,11 +153,7 @@ export class ProductsWidget extends Component {
this.updateProductList();
return ProductIds;
} catch (error) {
const identifiedError = identifyError(error);
if (
identifiedError instanceof ConnectionLostError ||
identifiedError instanceof ConnectionAbortedError
) {
if (error instanceof ConnectionLostError || error instanceof ConnectionAbortedError) {
return this.popup.add(OfflineErrorPopup, {
title: _t("Network Error"),
body: _t(