[input-output-hk/cardano-sl] [CBR-374] Catch all errors thrown by new data layer (#3464)

parsonsmatt requested changes on this pull request.

> @@ -30,6 +31,12 @@ instance Applicative InDb where
pure = InDb
InDb f <*> InDb x = InDb (f x)

+instance ToJSON a => ToJSON (InDb a) where
+ toJSON = toJSON . _fromDb
+
+instance FromJSON a => FromJSON (InDb a) where
+ parseJSON = fmap InDb . parseJSON

These instances are the same you’d get from `GeneralizedNewtypeDeriving`

> + ) => WalletException { getWalletException :: e }
+
+instance Prelude.Show WalletException where
+ show (WalletException e) = Prelude.show e
+
+instance Exception WalletException
+
+— | Wrap a wallet exception in a proper type that can be caught later
+throwWalletM ::
+ ( Exception e
+ , MonadThrow m
+ , HasDiagnostic e
+ , ToHttpErrorStatus e
+ ) => e -> m a
+throwWalletM =
+ throwM . WalletException

We shouldn’t need this. Instead we should use `throwM` directly, and have the `Exception` instances for our types wrap in `WalletException`.