Rename Error component to ErrorModal

`Error` is a built-in type in typescript, we don't want to have an
accidental clash.

Bumped into this when doing:

    try {
      // ...
    } catch (error: unknown) {
      if(error instanceof Error) {
        // ...
      }
    }

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-10-08 10:11:39 +02:00
parent 3ce7aada0f
commit 7d1f226798
9 changed files with 21 additions and 18 deletions
+2 -2
View File
@@ -2,7 +2,7 @@
import { get } from "svelte/store";
import { Connection, state } from "@app/session";
import type { Err } from "@app/error";
import Error from "@app/Error.svelte";
import ErrorModal from "@app/ErrorModal.svelte";
import type { Config } from "@app/config";
import ConnectWallet from "@app/components/Modal/ConnectWallet.svelte";
import Button from "@app/Button.svelte";
@@ -52,7 +52,7 @@
uri={$walletConnectState.uri}
on:close={onModalClose} />
{:else if error}
<Error
<ErrorModal
floating
emoji="👛"
title="Connection failed"
+4 -4
View File
@@ -1,9 +1,9 @@
import Error from "./Error.svelte";
import ErrorModal from "./ErrorModal.svelte";
import { Failure } from "@app/error";
describe("Error", () => {
it("should show passed in props", () => {
cy.mount(Error, {
cy.mount(ErrorModal, {
props: {
subtitle: "Subtitle of Modal",
error: {
@@ -21,7 +21,7 @@ describe("Error", () => {
});
it("should show custom error message", () => {
cy.mount(Error, {
cy.mount(ErrorModal, {
props: {
subtitle: "Subtitle of Modal",
message: "Error message to check for",
@@ -31,7 +31,7 @@ describe("Error", () => {
});
it("should change button label to Close when floating", () => {
cy.mount(Error, {
cy.mount(ErrorModal, {
props: {
title: "Title of Modal",
subtitle: "Subtitle of Modal",
+2 -2
View File
@@ -16,7 +16,7 @@
import { session } from "@app/session";
import { Org } from "@app/base/orgs/Org";
import Message from "@app/Message.svelte";
import Error from "@app/Error.svelte";
import ErrorModal from "@app/ErrorModal.svelte";
import { User } from "@app/base/users/User";
import Projects from "@app/base/seeds/View/Projects.svelte";
import { MissingReverseRecord, NotFoundError } from "@app/error";
@@ -491,6 +491,6 @@
title={addressOrName}
subtitle="Sorry, the requested name has no reverse record set." />
{:else}
<Error error={err} />
<ErrorModal error={err} />
{/if}
{/await}
+5 -2
View File
@@ -4,7 +4,7 @@
import type { Config } from "@app/config";
import Loading from "@app/Loading.svelte";
import Modal from "@app/Modal.svelte";
import Err from "@app/Error.svelte";
import ErrorModal from "@app/ErrorModal.svelte";
import type { State } from "@app/utils";
import { Status } from "@app/utils";
import { withdraw } from "./lib";
@@ -51,7 +51,10 @@
</style>
{#if error}
<Err title="Transaction failed" message={error.message} on:close={back} />
<ErrorModal
title="Transaction failed"
message={error.message}
on:close={back} />
{:else}
<Modal>
<span slot="title">
+2 -2
View File
@@ -4,7 +4,7 @@
import New from "@app/base/registrations/New.svelte";
import Submit from "@app/base/registrations/Submit.svelte";
import View from "@app/base/registrations/View.svelte";
import Error from "@app/Error.svelte";
import ErrorModal from "@app/ErrorModal.svelte";
import type { Config } from "@app/config";
import type { Session } from "@app/session";
import { getSearchParam } from "@app/utils";
@@ -29,7 +29,7 @@
owner={getSearchParam("owner", location)}
{session} />
{:else}
<Error
<ErrorModal
message={"You must connect your wallet to register"}
on:close={() => navigate("/registrations")} />
{/if}
+2 -2
View File
@@ -7,7 +7,7 @@
import type { Config } from "@app/config";
import Loading from "@app/Loading.svelte";
import Modal from "@app/Modal.svelte";
import Err from "@app/Error.svelte";
import ErrorModal from "@app/ErrorModal.svelte";
import BlockTimer from "@app/BlockTimer.svelte";
import Button from "@app/Button.svelte";
@@ -54,7 +54,7 @@
</svelte:head>
{#if error}
<Err
<ErrorModal
title="Transaction failed"
message={error.message}
on:close={() => navigate("/registrations")} />
+3 -3
View File
@@ -10,7 +10,7 @@
import Form from "@app/Form.svelte";
import type { Field } from "@app/Form.svelte";
import { assert } from "@app/error";
import Error from "@app/Error.svelte";
import ErrorModal from "@app/ErrorModal.svelte";
import { isAddressEqual, isReverseRecordSet } from "@app/utils";
import Button from "@app/Button.svelte";
@@ -235,11 +235,11 @@
{#if state.status === Status.Loading}
<Loading />
{:else if state.status === Status.Failed}
<Error
<ErrorModal
title="Registration could not be loaded"
on:close={() => navigate("/registrations")}>
{state.error}
</Error>
</ErrorModal>
{:else if state.status === Status.NotFound}
<Modal subtle>
<span slot="title" class="secondary">
+1 -1
View File
@@ -6,7 +6,7 @@
import { formatAddress, isAddressEqual } from "@app/utils";
import { Org } from "@app/base/orgs/Org";
import type { User } from "@app/base/users/User";
import ErrorModal from "@app/Error.svelte";
import ErrorModal from "@app/ErrorModal.svelte";
import Address from "@app/Address.svelte";
import * as utils from "@app/utils";
import Button from "@app/Button.svelte";