@@ -3,6 +3,8 @@ module Node.Process
33 ( onBeforeExit
44 , onExit
55 , onSignal
6+ , onUncaughtException
7+ , onUnhandledRejection
68 , argv
79 , execArgv
810 , execPath
@@ -24,17 +26,16 @@ module Node.Process
2426
2527import Prelude
2628
27- import Effect (Effect )
28-
2929import Data.Maybe (Maybe )
3030import Data.Posix (Pid )
3131import Data.Posix.Signal (Signal )
3232import Data.Posix.Signal as Signal
33+ import Effect (Effect )
34+ import Effect.Exception (Error )
3335import Foreign.Object as FO
3436import Node.Platform (Platform )
3537import Node.Platform as Platform
3638import Node.Stream (Readable , Writable )
37-
3839import Unsafe.Coerce (unsafeCoerce )
3940
4041-- YOLO
@@ -56,6 +57,23 @@ foreign import onBeforeExit :: Effect Unit -> Effect Unit
5657-- | to exit with.
5758foreign import onExit :: (Int -> Effect Unit ) -> Effect Unit
5859
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+
5977foreign import onSignalImpl :: String -> Effect Unit -> Effect Unit
6078
6179-- | Install a handler for a particular signal.
0 commit comments