git.iko.soy/distributed-process
on master help sign in
bury ProcessExitException as far away from users as possible
commitc88c5c052bc262006ab100b79ac9b4994f5a8dbb authorTim Watson <tim@rabbitmq.com> dateThu 17 Jan 2013, 22:15 (14 years ago) parentd225580
4 files changed+23−22
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+2−18 distributed-process/src/Control/Distributed/Process/Internal/Types.hs+19−1 distributed-process/src/Control/Distributed/Process/Node.hs+1−1 distributed-process/tests/TestCH.hs+1−2
distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs+2−18
@@ -29,7 +29,7 @@ module Control.Distributed.Process.Internal.Primitives
2929 , kill
3030 , exit
3131 , catchExit
32− , ProcessExitException(..)
32+ , ProcessExitException()
3333 , getSelfPid
3434 , getSelfNode
3535 , ProcessInfo(..)
@@ -139,6 +139,7 @@ import Control.Distributed.Process.Internal.Types
139139 , TypedChannel(..)
140140 , SendPortId(..)
141141 , Identifier(..)
142+ , ProcessExitException(..)
142143 , DidUnmonitor(..)
143144 , DidUnlinkProcess(..)
144145 , DidUnlinkNode(..)
@@ -370,23 +371,6 @@ exit :: Serializable a => ProcessId -> a -> Process ()
370371-- 'monitor' or 'link' request.
371372exit them reason = sendCtrlMsg Nothing (Exit them (createMessage reason))
372373
373−-- | Internal exception thrown indirectly by 'exit'
374−data ProcessExitException =
375− ProcessExitException !ProcessId !Message
376− deriving Typeable
377−
378−instance Exception ProcessExitException
379−instance Show ProcessExitException where
380− show = showProcessExit
381−
382−showProcessExit :: ProcessExitException -> String
383−showProcessExit (ProcessExitException pid reason) =
384− case messageFingerprint reason == fingerprint (undefined :: String) of
385− True -> "origin=" ++ (show pid) ++ ",reason=" ++ decoded
386− False -> "origin=" ++ show pid
387− where decoded :: String
388− !decoded = decode (messageEncoding reason)
389−
390374-- | Catches ProcessExitException
391375catchExit :: forall a b . (Show a, Serializable a)
392376 => Process b
distributed-process/src/Control/Distributed/Process/Internal/Types.hs+19−1
@@ -36,6 +36,7 @@ module Control.Distributed.Process.Internal.Types
3636 , ProcessMonitorNotification(..)
3737 , NodeMonitorNotification(..)
3838 , PortMonitorNotification(..)
39+ , ProcessExitException(..)
3940 , ProcessLinkException(..)
4041 , NodeLinkException(..)
4142 , PortLinkException(..)
@@ -72,7 +73,7 @@ import System.Mem.Weak (Weak)
7273import Data.Map (Map)
7374import Data.Int (Int32)
7475import Data.Typeable (Typeable)
75−import Data.Binary (Binary(put, get), putWord8, getWord8, encode)
76+import Data.Binary (Binary(put, get), putWord8, getWord8, encode, decode)
7677import qualified Data.ByteString as BSS (ByteString, concat, copy)
7778import qualified Data.ByteString.Lazy as BSL
7879 ( ByteString
@@ -370,6 +371,23 @@ data ProcessRegistrationException =
370371 ProcessRegistrationException !String
371372 deriving (Typeable, Show)
372373
374+-- | Internal exception thrown indirectly by 'exit'
375+data ProcessExitException =
376+ ProcessExitException !ProcessId !Message
377+ deriving Typeable
378+
379+instance Exception ProcessExitException
380+instance Show ProcessExitException where
381+ show = showProcessExit
382+
383+showProcessExit :: ProcessExitException -> String
384+showProcessExit (ProcessExitException pid reason) =
385+ case messageFingerprint reason == fingerprint (undefined :: String) of
386+ True -> "origin=" ++ (show pid) ++ ",reason=" ++ decoded
387+ False -> "origin=" ++ show pid
388+ where decoded :: String
389+ !decoded = decode (messageEncoding reason)
390+
373391instance Exception ProcessLinkException
374392instance Exception NodeLinkException
375393instance Exception PortLinkException
distributed-process/src/Control/Distributed/Process/Node.hs+1−1
@@ -112,6 +112,7 @@ import Control.Distributed.Process.Internal.Types
112112 , ProcessMonitorNotification(..)
113113 , NodeMonitorNotification(..)
114114 , PortMonitorNotification(..)
115+ , ProcessExitException(..)
115116 , ProcessLinkException(..)
116117 , NodeLinkException(..)
117118 , PortLinkException(..)
@@ -152,7 +153,6 @@ import Control.Distributed.Process.Internal.Primitives
152153 , receiveWait
153154 , match
154155 , sendChan
155− , ProcessExitException(..)
156156 )
157157import Control.Distributed.Process.Internal.Types (SendPort)
158158import qualified Control.Distributed.Process.Internal.Closure.BuiltIn as BuiltIn (remoteTable)
distributed-process/tests/TestCH.hs+1−2
@@ -4,7 +4,6 @@ module Main where
44import Prelude hiding (catch)
55#endif
66
7−
87import Data.Binary (Binary(..))
98import Data.Typeable (Typeable)
109import Data.Foldable (forM_)
@@ -31,9 +30,9 @@ import Control.Distributed.Process
3130import Control.Distributed.Process.Internal.Types
3231 ( NodeId(nodeAddress)
3332 , LocalNode(localEndPoint)
33+ , ProcessExitException(..)
3434 )
3535import Control.Distributed.Process.Node
36−import Control.Distributed.Process.Internal.Primitives
3736import Control.Distributed.Process.Serializable (Serializable)
3837
3938import Test.HUnit (Assertion)