Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bury ProcessExitException as far away from users as possible

  • Loading branch information...
commit c88c5c052bc262006ab100b79ac9b4994f5a8dbb 1 parent d225580
@hyperthunk hyperthunk authored
View
20 distributed-process/src/Control/Distributed/Process/Internal/Primitives.hs
@@ -29,7 +29,7 @@ module Control.Distributed.Process.Internal.Primitives
, kill
, exit
, catchExit
- , ProcessExitException(..)
+ , ProcessExitException()
, getSelfPid
, getSelfNode
, ProcessInfo(..)
@@ -139,6 +139,7 @@ import Control.Distributed.Process.Internal.Types
, TypedChannel(..)
, SendPortId(..)
, Identifier(..)
+ , ProcessExitException(..)
, DidUnmonitor(..)
, DidUnlinkProcess(..)
, DidUnlinkNode(..)
@@ -370,23 +371,6 @@ exit :: Serializable a => ProcessId -> a -> Process ()
-- 'monitor' or 'link' request.
exit them reason = sendCtrlMsg Nothing (Exit them (createMessage reason))
--- | Internal exception thrown indirectly by 'exit'
-data ProcessExitException =
- ProcessExitException !ProcessId !Message
- deriving Typeable
-
-instance Exception ProcessExitException
-instance Show ProcessExitException where
- show = showProcessExit
-
-showProcessExit :: ProcessExitException -> String
-showProcessExit (ProcessExitException pid reason) =
- case messageFingerprint reason == fingerprint (undefined :: String) of
- True -> "origin=" ++ (show pid) ++ ",reason=" ++ decoded
- False -> "origin=" ++ show pid
- where decoded :: String
- !decoded = decode (messageEncoding reason)
-
-- | Catches ProcessExitException
catchExit :: forall a b . (Show a, Serializable a)
=> Process b
View
20 distributed-process/src/Control/Distributed/Process/Internal/Types.hs
@@ -36,6 +36,7 @@ module Control.Distributed.Process.Internal.Types
, ProcessMonitorNotification(..)
, NodeMonitorNotification(..)
, PortMonitorNotification(..)
+ , ProcessExitException(..)
, ProcessLinkException(..)
, NodeLinkException(..)
, PortLinkException(..)
@@ -72,7 +73,7 @@ import System.Mem.Weak (Weak)
import Data.Map (Map)
import Data.Int (Int32)
import Data.Typeable (Typeable)
-import Data.Binary (Binary(put, get), putWord8, getWord8, encode)
+import Data.Binary (Binary(put, get), putWord8, getWord8, encode, decode)
import qualified Data.ByteString as BSS (ByteString, concat, copy)
import qualified Data.ByteString.Lazy as BSL
( ByteString
@@ -370,6 +371,23 @@ data ProcessRegistrationException =
ProcessRegistrationException !String
deriving (Typeable, Show)
+-- | Internal exception thrown indirectly by 'exit'
+data ProcessExitException =
+ ProcessExitException !ProcessId !Message
+ deriving Typeable
+
+instance Exception ProcessExitException
+instance Show ProcessExitException where
+ show = showProcessExit
+
+showProcessExit :: ProcessExitException -> String
+showProcessExit (ProcessExitException pid reason) =
+ case messageFingerprint reason == fingerprint (undefined :: String) of
+ True -> "origin=" ++ (show pid) ++ ",reason=" ++ decoded
+ False -> "origin=" ++ show pid
+ where decoded :: String
+ !decoded = decode (messageEncoding reason)
+
instance Exception ProcessLinkException
instance Exception NodeLinkException
instance Exception PortLinkException
View
2  distributed-process/src/Control/Distributed/Process/Node.hs
@@ -112,6 +112,7 @@ import Control.Distributed.Process.Internal.Types
, ProcessMonitorNotification(..)
, NodeMonitorNotification(..)
, PortMonitorNotification(..)
+ , ProcessExitException(..)
, ProcessLinkException(..)
, NodeLinkException(..)
, PortLinkException(..)
@@ -152,7 +153,6 @@ import Control.Distributed.Process.Internal.Primitives
, receiveWait
, match
, sendChan
- , ProcessExitException(..)
)
import Control.Distributed.Process.Internal.Types (SendPort)
import qualified Control.Distributed.Process.Internal.Closure.BuiltIn as BuiltIn (remoteTable)
View
3  distributed-process/tests/TestCH.hs
@@ -4,7 +4,6 @@ module Main where
import Prelude hiding (catch)
#endif
-
import Data.Binary (Binary(..))
import Data.Typeable (Typeable)
import Data.Foldable (forM_)
@@ -31,9 +30,9 @@ import Control.Distributed.Process
import Control.Distributed.Process.Internal.Types
( NodeId(nodeAddress)
, LocalNode(localEndPoint)
+ , ProcessExitException(..)
)
import Control.Distributed.Process.Node
-import Control.Distributed.Process.Internal.Primitives
import Control.Distributed.Process.Serializable (Serializable)
import Test.HUnit (Assertion)
Please sign in to comment.
Something went wrong with that request. Please try again.