Skip to content

Commit

Permalink
Improve the error message for "create dao" button (solana-labs#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
nramadas authored Jun 29, 2022
1 parent 1af75db commit 1729f85
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
9 changes: 8 additions & 1 deletion components/ConnectWalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
} from '../utils/wallet-adapters'
import Switch from './Switch'
import { TwitterIcon } from './icons'
import { notify } from '@utils/notifications'

const StyledWalletProviderLabel = styled.p`
font-size: 0.65rem;
Expand Down Expand Up @@ -78,7 +79,13 @@ const ConnectWalletButton = (props) => {
} else {
await current?.connect()
}
} catch (e) {
} catch (e: any) {
if (e.name === 'WalletNotReadyError') {
notify({
type: 'error',
message: 'You must have a wallet installed to connect',
})
}
console.warn('handleConnectDisconnect', e)
}
}
Expand Down
17 changes: 12 additions & 5 deletions pages/realms/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,20 @@ const Realms = () => {
const handleCreateRealmButtonClick = async () => {
if (!connected) {
try {
if (wallet) await wallet.connect()
if (wallet) {
await wallet.connect()
} else {
throw new Error('You need to connect a wallet to continue')
}
} catch (error) {
const err = error as Error
return notify({
type: 'error',
message: err.message,
})
let message = err.message

if (err.name === 'WalletNotReadyError') {
message = 'You must connect a wallet to create a DAO'
}

return notify({ message, type: 'error' })
}
}
router.push(fmtUrlWithCluster(`/realms/new`))
Expand Down

0 comments on commit 1729f85

Please sign in to comment.