jherve пре 1 година
родитељ
комит
929beef6b9
1 измењених фајлова са 13 додато и 4 уклоњено
  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 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.Either (Either(..), either)
 import Data.Traversable (class Traversable, traverse)
 import Data.Traversable (class Traversable, traverse)
 import Effect (Effect)
 import Effect (Effect)
@@ -27,9 +27,18 @@ run :: forall t.
   => Proxy t
   => Proxy t
   -> Document
   -> Document
   -> Effect (Either String Output)
   -> 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.
 runToDetached :: forall t.
   Traversable t
   Traversable t