on master help sign in
Log exceptions
1797495Tom Smalley
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
@@ -316,7 +316,8 @@ runBatch send sendSync = "\
316 \ catch (err) {\n\
316 \ catch (err) {\n\
317 \ var n = ++jsaddle_index;\n\
317 \ var n = ++jsaddle_index;\n\
318 \ jsaddle_values.set(n, err);\n\
318 \ jsaddle_values.set(n, err);\n\
319+ \ console.log(err);\n\
319− \ " <> send "{\"tag\": \"BatchResults\", \"contents\": [batch[2], {\"tag\": \"Failure\", \"contents\": [callbacksToFree, results, n]}]}" <> "\n\
320+ \ " <> send "{\"tag\": \"BatchResults\", \"contents\": [batch[2], {\"tag\": \"Failure\", \"contents\": [callbacksToFree, results, n, String(err)]}]}" <> "\n\
320 \ }\n\
321 \ }\n\
321 \ if(inCallback == 1) {\n\
322 \ if(inCallback == 1) {\n\
322 \ while(asyncBatch !== null) {\n\
323 \ while(asyncBatch !== null) {\n\
jsaddle/src/Language/Javascript/JSaddle/Types.hs+1−1
@@ -503,7 +503,7 @@ instance ToJSON Result where
503instance FromJSON Result
503instance FromJSON Result
504
504
505data BatchResults = Success [JSValueReceived] [Result]
505data BatchResults = Success [JSValueReceived] [Result]
506− | Failure [JSValueReceived] [Result] JSValueReceived
506+ | Failure [JSValueReceived] [Result] JSValueReceived String
507 deriving (Show, Generic)
507 deriving (Show, Generic)
508
508
509instance ToJSON BatchResults where
509instance ToJSON BatchResults where