Merge pull request #89 from polkadot-api/vo/fix-storage-crash
fix: capture failed storage queries
This commit is contained in:
@@ -100,6 +100,13 @@ const DecodedResultDisplay: FC<{
|
||||
storageSubscription: StorageSubscription
|
||||
subscriptionKey: string
|
||||
}> = ({ storageSubscription, subscriptionKey }) => {
|
||||
if ("error" in storageSubscription) {
|
||||
return (
|
||||
<div className="text-sm text-foreground/50">
|
||||
{storageSubscription.error}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
if (!("result" in storageSubscription)) {
|
||||
return <div className="text-sm text-foreground/50">Loading…</div>
|
||||
}
|
||||
@@ -170,6 +177,14 @@ const DecodedResultDisplay: FC<{
|
||||
const JsonResultDisplay: FC<{
|
||||
storageSubscription: StorageSubscription
|
||||
}> = ({ storageSubscription }) => {
|
||||
if ("error" in storageSubscription) {
|
||||
return (
|
||||
<div className="text-sm text-foreground/50">
|
||||
{storageSubscription.error}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!("result" in storageSubscription)) {
|
||||
return <div className="text-sm text-foreground/50">Loading…</div>
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
} from "@react-rxjs/utils"
|
||||
import { Binary } from "polkadot-api"
|
||||
import {
|
||||
catchError,
|
||||
combineLatest,
|
||||
concat,
|
||||
distinctUntilChanged,
|
||||
@@ -168,7 +169,8 @@ export type StorageSubscription = {
|
||||
single: boolean
|
||||
paused: boolean
|
||||
completed: boolean
|
||||
} & ({ result: unknown } | {})
|
||||
} & ({ result: unknown } | { error: string } | {})
|
||||
|
||||
const [getStorageSubscription$, storageSubscriptionKeyChange$] = partitionByKey(
|
||||
newStorageSubscription$,
|
||||
() => uuid(),
|
||||
@@ -198,6 +200,18 @@ const [getStorageSubscription$, storageSubscriptionKeyChange$] = partitionByKey(
|
||||
paused,
|
||||
completed,
|
||||
})),
|
||||
catchError((ex) => {
|
||||
console.error(ex)
|
||||
return [
|
||||
{
|
||||
...props,
|
||||
paused: false,
|
||||
completed: true,
|
||||
error:
|
||||
ex instanceof Error ? `Error: ${ex.message}` : "(Errored)",
|
||||
} satisfies StorageSubscription,
|
||||
]
|
||||
}),
|
||||
)
|
||||
}),
|
||||
takeUntil(merge(removeStorageSubscription$(id), selectedChainChanged$)),
|
||||
|
||||
Reference in New Issue
Block a user