Skip to content
Permalink
Browse files

correctly handle 'ErrWithRootKey' mapping to server errors

  • Loading branch information...
KtorZ committed May 15, 2019
1 parent 9a7974e commit 22a9ecbf5af970a5a9d8e5df7742b2f2f9814666
Showing with 10 additions and 2 deletions.
  1. +1 −0 lib/core/src/Cardano/Wallet.hs
  2. +9 −2 lib/core/src/Cardano/Wallet/Api/Server.hs
@@ -30,6 +30,7 @@ module Cardano.Wallet
, ErrUpdatePassphrase (..)
, ErrWalletAlreadyExists (..)
, ErrWithRootKey (..)
, ErrWrongPassphrase(..)

-- * Construction
, newWalletLayer
@@ -24,6 +24,8 @@ import Cardano.Wallet
, ErrSubmitTx (..)
, ErrUpdatePassphrase (..)
, ErrWalletAlreadyExists (..)
, ErrWithRootKey (..)
, ErrWrongPassphrase (..)
, WalletLayer
)
import Cardano.Wallet.Api
@@ -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
@@ -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.
You can’t perform that action at this time.