on master help sign in
Merge pull request #88 from obsidiansystems/log-exceptions
c745863Hamish Mackenzie
jsaddle/src/Language/Javascript/JSaddle/Run.hs+2−1
@@ -227,10 +227,11 @@ runJavaScript sendBatch entryPoint = do
227 zipWithM_ putMVar resultMVars results
227 zipWithM_ putMVar resultMVars results
228 forM_ callbacksToFree $ \(JSValueReceived val) ->
228 forM_ callbacksToFree $ \(JSValueReceived val) ->
229 atomically (modifyTVar' callbacks (M.delete val))
229 atomically (modifyTVar' callbacks (M.delete val))
230− (_, Failure callbacksToFree results exception) -> do
230+ (_, Failure callbacksToFree results exception err) -> do
231 -- The exception will only be rethrown in Haskell if/when one of the
231 -- The exception will only be rethrown in Haskell if/when one of the
232 -- missing results (if any) is evaluated.
232 -- missing results (if any) is evaluated.
233 putStrLn "A JavaScript exception was thrown! (may not reach Haskell code)"
233 putStrLn "A JavaScript exception was thrown! (may not reach Haskell code)"
234+ putStrLn err
234 zipWithM_ putMVar resultMVars $ results <> repeat (ThrowJSValue exception)
235 zipWithM_ putMVar resultMVars $ results <> repeat (ThrowJSValue exception)
235 forM_ callbacksToFree $ \(JSValueReceived val) ->
236 forM_ callbacksToFree $ \(JSValueReceived val) ->
236 atomically (modifyTVar' callbacks (M.delete val))
237 atomically (modifyTVar' callbacks (M.delete val))
jsaddle/src/Language/Javascript/JSaddle/Run/Files.hs+2−1
@@ -315,7 +315,8 @@ runBatch send sendSync = "\
315 \ catch (err) {\n\
315 \ catch (err) {\n\
316 \ var n = ++jsaddle_index;\n\
316 \ var n = ++jsaddle_index;\n\
317 \ jsaddle_values.set(n, err);\n\
317 \ jsaddle_values.set(n, err);\n\
318+ \ console.log(err);\n\
318− \ " <> send "{\"tag\": \"BatchResults\", \"contents\": [batch[2], {\"tag\": \"Failure\", \"contents\": [callbacksToFree, results, n]}]}" <> "\n\
319+ \ " <> send "{\"tag\": \"BatchResults\", \"contents\": [batch[2], {\"tag\": \"Failure\", \"contents\": [callbacksToFree, results, n, String(err)]}]}" <> "\n\
319 \ }\n\
320 \ }\n\
320 \ if(inCallback == 1) {\n\
321 \ if(inCallback == 1) {\n\
321 \ while(asyncBatch !== null) {\n\
322 \ while(asyncBatch !== null) {\n\
jsaddle/src/Language/Javascript/JSaddle/Types.hs+1−1
@@ -504,7 +504,7 @@ instance ToJSON Result where
504instance FromJSON Result
504instance FromJSON Result
505
505
506data BatchResults = Success [JSValueReceived] [Result]
506data BatchResults = Success [JSValueReceived] [Result]
507− | Failure [JSValueReceived] [Result] JSValueReceived
507+ | Failure [JSValueReceived] [Result] JSValueReceived String
508 deriving (Show, Generic)
508 deriving (Show, Generic)
509
509
510instance ToJSON BatchResults where
510instance ToJSON BatchResults where