Explorar el Código

Yet another layer

jherve hace 1 año
padre
commit
c71097bbbc
Se han modificado 1 ficheros con 13 adiciones y 4 borrados
  1. 13 4
      src/LinkedIn/Output.purs

+ 13 - 4
src/LinkedIn/Output.purs

@@ -2,7 +2,7 @@ module LinkedIn.Output (run, runToDetached, toOutput) where
 
 import Prelude
 
-import Control.Monad.Except (ExceptT, except, lift, runExceptT)
+import Control.Monad.Except (ExceptT, except, lift, runExceptT, withExceptT)
 import Data.Either (Either(..), either)
 import Data.Traversable (class Traversable, traverse)
 import Effect (Effect)
@@ -27,9 +27,18 @@ run :: forall t.
   => Proxy t
   -> Document
   -> Effect (Either String Output)
-run prox dom = do
-  detached <- runToDetached prox dom
-  pure $ extract LE.extract $ toUI detached
+run prox dom = runExceptT $ run' prox dom
+
+run' :: forall t.
+  Traversable t
+  => Extractible t
+  => Proxy t
+  -> Document
+  -> ExceptT String Effect Output
+run' prox dom = do
+  detached <- withExceptT (\_ -> "Error on detach") $ runToDetached'' prox dom
+  asUI <- except $ fromDetachedToUI detached
+  except $ LE.extract asUI
 
 runToDetached :: forall t.
   Traversable t