Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
LIVE-921 Throw specific error when app not in provider (#1689)
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-cortes authored Feb 7, 2022
1 parent bf5493d commit 5a7df0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/apps/logic.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { $Shape } from "utility-types";
import { Subject } from "rxjs";
import flatMap from "lodash/flatMap";
import invariant from "invariant";
import semver from "semver";
import { getDeviceModel } from "@ledgerhq/devices";
import type { App } from "../types/manager";
Expand All @@ -17,7 +16,7 @@ import {
findCryptoCurrencyById,
isCurrencySupported,
} from "../currencies";
import { LatestFirmwareVersionRequired } from "../errors";
import { LatestFirmwareVersionRequired, NoSuchAppOnProvider } from "../errors";

export const initState = (
{
Expand Down Expand Up @@ -292,6 +291,7 @@ export const reducer = (state: State, action: Action): State => {
// No app found but fw update is available
if (
!depApp &&
state.firmware?.updateAvailable?.final?.version &&
semver.lt(
state.deviceInfo.version,
state.firmware?.updateAvailable?.final?.version
Expand All @@ -306,7 +306,10 @@ export const reducer = (state: State, action: Action): State => {
);
}

invariant(depApp, "no such app '%s'", name);
if (!depApp) {
throw new NoSuchAppOnProvider("", { appName: name });
}

const deps = depApp.dependencies;
const dependentsOfDep = flatMap(deps, (dep) =>
findDependents(state.appByName, dep)
Expand Down
3 changes: 3 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ export const SatStackDescriptorNotImported = createCustomErrorClass(
export const SwapNoAvailableProviders = createCustomErrorClass(
"SwapNoAvailableProviders"
);
export const NoSuchAppOnProvider = createCustomErrorClass(
"NoSuchAppOnProvider"
);
export const SwapExchangeRateAmountTooLow = createCustomErrorClass(
"SwapExchangeRateAmountTooLow"
);
Expand Down

1 comment on commit 5a7df0b

@vercel
Copy link

@vercel vercel bot commented on 5a7df0b Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.