@@ -3,6 +3,8 @@ module Node.Process
3
3
( onBeforeExit
4
4
, onExit
5
5
, onSignal
6
+ , onUncaughtException
7
+ , onUnhandledRejection
6
8
, argv
7
9
, execArgv
8
10
, execPath
@@ -24,17 +26,16 @@ module Node.Process
24
26
25
27
import Prelude
26
28
27
- import Effect (Effect )
28
-
29
29
import Data.Maybe (Maybe )
30
30
import Data.Posix (Pid )
31
31
import Data.Posix.Signal (Signal )
32
32
import Data.Posix.Signal as Signal
33
+ import Effect (Effect )
34
+ import Effect.Exception (Error )
33
35
import Foreign.Object as FO
34
36
import Node.Platform (Platform )
35
37
import Node.Platform as Platform
36
38
import Node.Stream (Readable , Writable )
37
-
38
39
import Unsafe.Coerce (unsafeCoerce )
39
40
40
41
-- YOLO
@@ -56,6 +57,23 @@ foreign import onBeforeExit :: Effect Unit -> Effect Unit
56
57
-- | to exit with.
57
58
foreign import onExit :: (Int -> Effect Unit ) -> Effect Unit
58
59
60
+ -- | Install a handler for uncaught exceptions. The callback will be called
61
+ -- | when the process emits the `uncaughtException` event. The handler
62
+ -- | currently does not expose the second `origin` argument from the Node 12
63
+ -- | version of this event to maintain compatibility with older Node versions.
64
+ foreign import onUncaughtException :: (Error -> Effect Unit ) -> Effect Unit
65
+
66
+ -- | Install a handler for unhandled promise rejectionsgq. The callback will be
67
+ -- | called when the process emits the `unhandledRejection` event.
68
+ -- |
69
+ -- | The first argument to the handler can be whatever type the unhandled
70
+ -- | Promise yielded on rejection (typically, but not necessarily, an `Error`).
71
+ -- |
72
+ -- | The handler currently does not expose the type of the second argument,
73
+ -- | which is a `Promise`, in order to allow users of this library to choose
74
+ -- | their own PureScript `Promise` bindings.
75
+ foreign import onUnhandledRejection :: forall a b . (a -> b -> Effect Unit ) -> Effect Unit
76
+
59
77
foreign import onSignalImpl :: String -> Effect Unit -> Effect Unit
60
78
61
79
-- | Install a handler for a particular signal.
0 commit comments