Skip to content

Commit

Permalink
correctly handle 'ErrWithRootKey' mapping to server errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed May 15, 2019
1 parent 9a7974e commit 22a9ecb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/core/src/Cardano/Wallet.hs
Expand Up @@ -30,6 +30,7 @@ module Cardano.Wallet
, ErrUpdatePassphrase (..)
, ErrWalletAlreadyExists (..)
, ErrWithRootKey (..)
, ErrWrongPassphrase(..)

-- * Construction
, newWalletLayer
Expand Down
11 changes: 9 additions & 2 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Expand Up @@ -24,6 +24,8 @@ import Cardano.Wallet
, ErrSubmitTx (..)
, ErrUpdatePassphrase (..)
, ErrWalletAlreadyExists (..)
, ErrWithRootKey (..)
, ErrWrongPassphrase (..)
, WalletLayer
)
import Cardano.Wallet.Api
Expand Down Expand Up @@ -267,6 +269,11 @@ instance LiftHandler ErrWalletAlreadyExists where
handler = \case
ErrWalletAlreadyExists _ -> err409

instance LiftHandler ErrWithRootKey where
handler = \case
ErrWithRootKeyNoRootKey _ -> err404
ErrWithRootKeyWrongPassphrase ErrWrongPassphrase -> err403

instance LiftHandler ErrCreateUnsignedTx where
handler = \case
ErrCreateUnsignedTxNoSuchWallet _ -> err404
Expand All @@ -277,12 +284,12 @@ instance LiftHandler ErrSignTx where
handler = \case
ErrSignTx _ -> err500
ErrSignTxNoSuchWallet _ -> err410
ErrSignTxWithRootKey _ -> err403
ErrSignTxWithRootKey e -> handler e

instance LiftHandler ErrSubmitTx where
handler _ = err500

instance LiftHandler ErrUpdatePassphrase where
handler = \case
ErrUpdatePassphraseNoSuchWallet _ -> err404
ErrUpdatePassphraseWithRootKey _ -> err403
ErrUpdatePassphraseWithRootKey e -> handler e

0 comments on commit 22a9ecb

Please sign in to comment.