Skip to content

Commit

Permalink
chore(IT Wallet): [SIW-715] Remove deprecated errors mapping (#5281)
Browse files Browse the repository at this point in the history
## Short description
This PR removes the deprecated errors mapping function. Now each screen
_can_ implements a `ItwErrorMapping` function which handles the errors
mapping directly in the screen. This allow better tracking on which
error is displayed in a given screen and also avoid coupling all the
mapping into a single function.

## List of changes proposed in this pull request
- Removes `mapItwError` and `getItwGenericError` because deprecated and
not used anymore;
- Moves `getItwGenericMappedError` into a single new file under
`utils/itwErrorsUtils.ts`;
- Updates imports acorrdingly.

## How to test
Static checks.
  • Loading branch information
LazyAfternoons committed Dec 1, 2023
1 parent 77584d8 commit d5719a2
Show file tree
Hide file tree
Showing 37 changed files with 73 additions and 100 deletions.
2 changes: 1 addition & 1 deletion ts/features/it-wallet/saga/__tests__/itwWiaSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as matchers from "redux-saga-test-plan/matchers";
import * as O from "fp-ts/lib/Option";
import { handleWiaRequest } from "../itwWiaSaga";
import { idpSelector } from "../../../../store/reducers/authentication";
import { ItWalletErrorTypes } from "../../utils/errors/itwErrors";
import { ItWalletErrorTypes } from "../../utils/itwErrorsUtils";
import { getWia } from "../../utils/wia";
import { isCIEAuthenticationSupported } from "../../utils/cie";
import { itwWiaRequest } from "../../store/actions/itwWiaActions";
Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/saga/itwPidSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ActionType } from "typesafe-actions";
import * as O from "fp-ts/lib/Option";
import { itwWiaSelector } from "../store/reducers/itwWiaReducer";
import { getPid } from "../utils/pid";
import { ItWalletErrorTypes } from "../utils/errors/itwErrors";
import { ItWalletErrorTypes } from "../utils/itwErrorsUtils";
import {
itwCredentialsAddPid,
itwDecodePid,
Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/saga/itwRpInitializationSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Trust
} from "@pagopa/io-react-native-wallet";
import { itwRpInitialization } from "../store/actions/itwRpActions";
import { ItWalletErrorTypes } from "../utils/errors/itwErrors";
import { ItWalletErrorTypes } from "../utils/itwErrorsUtils";
import { ITW_WIA_KEY_TAG } from "../utils/wia";
import { itwWiaRequest } from "../store/actions/itwWiaActions";

Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/saga/itwRpPresentationSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
itwRpInitializationRequestObjectValueSelector
} from "../store/reducers/itwRpInitializationReducer";
import { itwRpPresentation } from "../store/actions/itwRpActions";
import { ItWalletErrorTypes } from "../utils/errors/itwErrors";
import { ItWalletErrorTypes } from "../utils/itwErrorsUtils";
import { ItwCredentialsPidSelector } from "../store/reducers/itwCredentialsReducer";
import { ITW_PID_KEY_TAG } from "../utils/pid";
import { itwWiaSelector } from "../store/reducers/itwWiaReducer";
Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/saga/itwWiaSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isSome } from "fp-ts/lib/Option";
import { Errors, Trust } from "@pagopa/io-react-native-wallet";
import DeviceInfo from "react-native-device-info";
import { idpSelector } from "../../../store/reducers/authentication";
import { ItWalletErrorTypes } from "../utils/errors/itwErrors";
import { ItWalletErrorTypes } from "../utils/itwErrorsUtils";
import { getWia } from "../utils/wia";
import { isCIEAuthenticationSupported } from "../utils/cie";
import { itwWiaRequest } from "../store/actions/itwWiaActions";
Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/saga/new/itwIssuanceSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
itwIssuanceGetCredential
} from "../../store/actions/new/itwIssuanceActions";
import { ITW_PID_KEY_TAG } from "../../utils/pid";
import { ItWalletErrorTypes } from "../../utils/errors/itwErrors";
import { ItWalletErrorTypes } from "../../utils/itwErrorsUtils";
import { ITW_WIA_KEY_TAG } from "../../utils/wia";

import { itwWiaRequest } from "../../store/actions/itwWiaActions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { showCancelAlert } from "../../../utils/alert";
import ROUTES from "../../../../../navigation/routes";
import { ITW_ROUTES } from "../../../navigation/ItwRoutes";
import ItwKoView from "../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../../utils/itwErrorsUtils";
import ItwTextInfo from "../../../components/ItwTextInfo";
import { useItwInfoBottomSheet } from "../../../hooks/useItwInfoBottomSheet";
import { itwIssuanceChecksDataSelector } from "../../../store/reducers/new/itwIssuanceReducer";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { showCancelAlert } from "../../../utils/alert";
import {
ItWalletError,
ItWalletErrorTypes,
ItwErrorMapping
} from "../../../utils/errors/itwErrors";
import { getItwGenericMappedError } from "../../../utils/errors/itwErrorsMapping";
ItwErrorMapping,
getItwGenericMappedError
} from "../../../utils/itwErrorsUtils";
import ItwKoView from "../../../components/ItwKoView";
import ROUTES from "../../../../../navigation/routes";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ import ItwCredentialClaimsList from "../../../components/ItwCredentialClaimsList
import { showCancelAlert } from "../../../utils/alert";
import ROUTES from "../../../../../navigation/routes";
import ItwKoView from "../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../utils/errors/itwErrorsMapping";
import {
getItwGenericMappedError,
ItWalletError
} from "../../../utils/itwErrorsUtils";
import { useOnFirstRender } from "../../../../../utils/hooks/useOnFirstRender";
import {
itwConfirmStoreCredential,
itwIssuanceGetCredential
} from "../../../store/actions/new/itwIssuanceActions";
import { itwIssuanceResultSelector } from "../../../store/reducers/new/itwIssuanceReducer";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import ItwLoadingSpinnerOverlay from "../../../components/ItwLoadingSpinnerOverlay";
import { ForceScrollDownView } from "../../../../../components/ForceScrollDownView";
import ItwFooterVerticalButtons from "../../../components/ItwFooterVerticalButtons";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ import { itwPidValueSelector } from "../../../store/reducers/itwPidReducer";
import { itwCredentialsAddPid } from "../../../store/actions/itwCredentialsActions";
import { itwActivationCompleted } from "../../../store/actions/itwActivationActions";
import { ItwCredentialsStateSelector } from "../../../store/reducers/itwCredentialsReducer";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import {
ItWalletError,
getItwGenericMappedError
} from "../../../utils/itwErrorsUtils";
import ItwContinueView from "../../../components/ItwContinueView";
import ItwKoView from "../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../utils/errors/itwErrorsMapping";

/**
* Renders an activation screen which displays a loading screen while the PID is being added and a success screen when the PID is added.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ import { itwWiaRequest } from "../../../store/actions/itwWiaActions";
import ItwContinueView from "../../../components/ItwContinueView";
import ItwLoadingSpinnerOverlay from "../../../components/ItwLoadingSpinnerOverlay";
import ItwKoView from "../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../utils/errors/itwErrorsMapping";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import {
getItwGenericMappedError,
ItWalletError
} from "../../../utils/itwErrorsUtils";

/**
* Renders the screen which displays the information about the authentication process to obtain a Wallet Instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import { itwPidSelector } from "../../../store/reducers/itwPidReducer";
import { itwPid } from "../../../store/actions/itwCredentialsActions";
import { itwActivationStop } from "../../../store/actions/itwActivationActions";
import ItwKoView from "../../../components/ItwKoView";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import { getItwGenericMappedError } from "../../../utils/errors/itwErrorsMapping";
import {
ItWalletError,
getItwGenericMappedError
} from "../../../utils/itwErrorsUtils";

/**
* ItwPidRequestScreen's navigation params.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ import BaseScreenComponent from "../../../../../../components/screens/BaseScreen
import { ItwParamsList } from "../../../../navigation/ItwParamsList";
import ItwLoadingSpinnerOverlay from "../../../../components/ItwLoadingSpinnerOverlay";
import ItwKoView from "../../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../../utils/errors/itwErrorsMapping";
import { ItWalletError } from "../../../../utils/errors/itwErrors";
import {
getItwGenericMappedError,
ItWalletError
} from "../../../../utils/itwErrorsUtils";

type ContentViewProps = {
decodedPid: PidWithToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { CredentialType, getPidDisplayData } from "../../utils/mocks";
import ItwClaimsWrapper from "../../components/ItwClaimsWrapper";
import { ITW_ROUTES } from "../../navigation/ItwRoutes";
import ItwKoView from "../../components/ItwKoView";
import { getItwGenericMappedError } from "../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../utils/itwErrorsUtils";

export type ContentViewParams = {
decodedPid: PidWithToken;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ItwParamsList } from "../../navigation/ItwParamsList";
import I18n from "../../../../i18n";
import BaseScreenComponent from "../../../../components/screens/BaseScreenComponent";
import ItwKoView from "../../components/ItwKoView";
import { getItwGenericMappedError } from "../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../utils/itwErrorsUtils";

// A mocked QR code to be used in the proximity flow
// TODO: remove this mocked QR code after the proximity flow is implemented [SIW-688]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { ItwParamsList } from "../../../../navigation/ItwParamsList";
import { getRpMock } from "../../../../utils/mocks";
import { ITW_ROUTES } from "../../../../navigation/ItwRoutes";
import ItwKoView from "../../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils";

/**
* This screen is used to perform different checks before initiating the presentation flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { useItwInfoBottomSheet } from "../../../../hooks/useItwInfoBottomSheet";
import { getRpMock } from "../../../../utils/mocks";
import { showCancelAlert } from "../../../../utils/alert";
import ItwKoView from "../../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils";
import { ForceScrollDownView } from "../../../../../../components/ForceScrollDownView";

type ContentViewParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import { ItwParamsList } from "../../../../navigation/ItwParamsList";
import { getRpMock } from "../../../../utils/mocks";
import ItwKoView from "../../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils";

/**
* This screen is used to perform different checks before initiating the presentation flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { itwRpInitialization } from "../../../../store/actions/itwRpActions";
import { rpPidMock } from "../../../../utils/mocks";
import { ITW_ROUTES } from "../../../../navigation/ItwRoutes";
import ItwKoView from "../../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils";
import { IOStackNavigationProp } from "../../../../../../navigation/params/AppParamsList";
import ItwContinueView from "../../../../components/ItwContinueView";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { ITW_ROUTES } from "../../../../navigation/ItwRoutes";
import interno from "../../../../../../../img/features/it-wallet/interno.png";
import { useItwInfoBottomSheet } from "../../../../hooks/useItwInfoBottomSheet";
import ItwKoView from "../../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils";
import ROUTES from "../../../../../../navigation/routes";
import { ForceScrollDownView } from "../../../../../../components/ForceScrollDownView";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import ItwLoadingSpinnerOverlay from "../../../../components/ItwLoadingSpinnerOv
import { IOStackNavigationProp } from "../../../../../../navigation/params/AppParamsList";
import ROUTES from "../../../../../../navigation/routes";
import ItwKoView from "../../../../components/ItwKoView";
import { getItwGenericMappedError } from "../../../../utils/errors/itwErrorsMapping";
import { getItwGenericMappedError } from "../../../../utils/itwErrorsUtils";

const ItwPrPidResultScreen = () => {
const dispatch = useIODispatch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { PidWithToken } from "@pagopa/io-react-native-wallet/lib/typescript/pid/
import { PidData } from "@pagopa/io-react-native-cie-pid";
import * as O from "fp-ts/lib/Option";

import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { PidResponse } from "../../utils/types";
import { StoredCredential } from "../reducers/itwCredentialsReducer";
import { CredentialCatalogAvailableItem } from "./../../utils/mocks";
Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/store/actions/itwRpActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionType, createAsyncAction } from "typesafe-actions";
import { Trust } from "@pagopa/io-react-native-wallet";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { RequestObject } from "../../utils/types";
import { RpData } from "../reducers/itwRpInitializationReducer";

Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/store/actions/itwWiaActions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionType, createAsyncAction } from "typesafe-actions";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";

/**
* Start ITW wallet instance attestation request.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
createAsyncAction,
createStandardAction
} from "typesafe-actions";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import { ItWalletError } from "../../../utils/itwErrorsUtils";
import { IssuanceData } from "../../reducers/new/itwIssuanceReducer";
import { CredentialDefinition, StartIssuanceFlow } from "../../../utils/types";
import { StoredCredential } from "../../reducers/itwCredentialsReducer";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionType, createAsyncAction } from "typesafe-actions";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import { ItWalletError } from "../../../utils/itwErrorsUtils";

/**
* Async action which starts the presentation checks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as O from "fp-ts/lib/Option";
import { Action } from "../../../../store/actions/types";
import { GlobalState } from "../../../../store/reducers/types";
import { itwCredentialsChecks } from "../actions/itwCredentialsActions";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { CredentialCatalogAvailableItem } from "../../utils/mocks";

export type ItwCredentialsChecksState = pot.Pot<
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
itwCredentialsAddCredential,
itwCredentialsAddPid
} from "../actions/itwCredentialsActions";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import {
CredentialConfigurationSchema,
CredentialDefinition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PidWithToken } from "@pagopa/io-react-native-wallet/lib/typescript/pid/
import { Action } from "../../../../store/actions/types";
import { GlobalState } from "../../../../store/reducers/types";
import { itwDecodePid } from "../actions/itwCredentialsActions";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { itwLifecycleOperational } from "../actions/itwLifecycleActions";

type ItwDecodedPidType = {
Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/store/reducers/itwPidReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getType } from "typesafe-actions";
import * as pot from "@pagopa/ts-commons/lib/pot";
import * as O from "fp-ts/lib/Option";
import { Action } from "../../../../store/actions/types";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { GlobalState } from "../../../../store/reducers/types";
import { itwPid } from "../actions/itwCredentialsActions";
import { PidResponse } from "../../utils/types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as pot from "@pagopa/ts-commons/lib/pot";
import * as O from "fp-ts/lib/Option";
import { Trust } from "@pagopa/io-react-native-wallet";
import { Action } from "../../../../store/actions/types";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { GlobalState } from "../../../../store/reducers/types";
import { itwRpInitialization } from "../actions/itwRpActions";
import { RequestObject } from "../../utils/types";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getType } from "typesafe-actions";
import * as pot from "@pagopa/ts-commons/lib/pot";
import * as O from "fp-ts/lib/Option";
import { Action } from "../../../../store/actions/types";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { GlobalState } from "../../../../store/reducers/types";
import { itwRpPresentation } from "../actions/itwRpActions";

Expand Down
2 changes: 1 addition & 1 deletion ts/features/it-wallet/store/reducers/itwWiaReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getType } from "typesafe-actions";
import * as O from "fp-ts/lib/Option";
import { Action } from "../../../../store/actions/types";
import { GlobalState } from "../../../../store/reducers/types";
import { ItWalletError } from "../../utils/errors/itwErrors";
import { ItWalletError } from "../../utils/itwErrorsUtils";
import { itwWiaRequest } from "../actions/itwWiaActions";
import { itwLifecycleOperational } from "../actions/itwLifecycleActions";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as O from "fp-ts/lib/Option";
import { getType } from "typesafe-actions";
import { Action } from "../../../../../store/actions/types";
import { GlobalState } from "../../../../../store/reducers/types";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import { ItWalletError } from "../../../utils/itwErrorsUtils";
import {
itwIssuanceChecks,
itwIssuanceGetCredential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as pot from "@pagopa/ts-commons/lib/pot";
import { getType } from "typesafe-actions";
import { Action } from "../../../../../store/actions/types";
import { GlobalState } from "../../../../../store/reducers/types";
import { ItWalletError } from "../../../utils/errors/itwErrors";
import { ItWalletError } from "../../../utils/itwErrorsUtils";
import {
itwPresentation,
itwPresentationChecks
Expand Down
57 changes: 0 additions & 57 deletions ts/features/it-wallet/utils/errors/itwErrorsMapping.ts

This file was deleted.

Loading

0 comments on commit d5719a2

Please sign in to comment.