Skip to content

Commit

Permalink
Merge pull request #1231 from rainlanguage/02/04/25-select-tokens-err…
Browse files Browse the repository at this point in the history
…or-message-from-rust
  • Loading branch information
hardyjosh authored Feb 6, 2025
2 parents e65e965 + 8dafc4f commit 8cdaa81
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions packages/ui-components/src/__tests__/SelectToken.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ describe('SelectToken', () => {
saveSelectToken: vi.fn().mockRejectedValue(new Error('Invalid address'))
} as unknown as DotrainOrderGui;

const { getByRole, findByText } = render(SelectToken, {
const screen = render(SelectToken, {
...mockProps,
gui: mockGuiWithError
});

const input = getByRole('textbox');
const input = screen.getByRole('textbox');
await user.type(input, 'invalid');
await waitFor(() => {
expect(findByText('Invalid token address.')).resolves.toBeInTheDocument();
expect(screen.getByTestId('error')).toBeInTheDocument();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@
await gui.saveSelectToken(tokenKey, currentTarget.value);
}
await getInfoForSelectedToken();
} catch {
error = 'Invalid token address.';
} catch (e) {
const errorMessage = (e as Error).message ? (e as Error).message : 'Invalid token address.';
error = errorMessage;
}
}
checking = false;
Expand All @@ -73,7 +74,7 @@
<span>{tokenInfo.name}</span>
</div>
{:else if error}
<div class="flex h-5 flex-row items-center gap-2">
<div class="flex h-5 flex-row items-center gap-2" data-testid="error">
<CloseCircleSolid class="h-5 w-5" color="red" />
<span>{error}</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
if (!vault.token?.key) return;
try {
tokenInfo = await gui.getTokenInfo(vault.token?.key);
} catch {
error = 'Error getting token info';
} catch (e) {
const errorMessage = (e as Error).message
? (e as Error).message
: 'Error getting token info.';
error = errorMessage;
}
};
Expand Down

0 comments on commit 8cdaa81

Please sign in to comment.