diff options
author | joe <joe@jerkface.net> | 2016-08-31 23:33:04 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2016-08-31 23:33:04 -0400 |
commit | 6734397a53e2160257a89f8c391d89ea4aa02ad4 (patch) | |
tree | 57da0c2ff30e97abb9e821e587172ecb6d5e15b5 /lib/GnuPGAgent.hs | |
parent | d8950d3ccdf51f308aa93f06c16f26b15a6c55c4 (diff) |
Better error reporting
Diffstat (limited to 'lib/GnuPGAgent.hs')
-rw-r--r-- | lib/GnuPGAgent.hs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/GnuPGAgent.hs b/lib/GnuPGAgent.hs index 7161b92..067e3bc 100644 --- a/lib/GnuPGAgent.hs +++ b/lib/GnuPGAgent.hs | |||
@@ -12,6 +12,7 @@ module GnuPGAgent | |||
12 | 12 | ||
13 | import Debug.Trace | 13 | import Debug.Trace |
14 | import Control.Monad | 14 | import Control.Monad |
15 | import ControlMaybe | ||
15 | import Data.Char | 16 | import Data.Char |
16 | import Data.OpenPGP | 17 | import Data.OpenPGP |
17 | import Data.OpenPGP.Util | 18 | import Data.OpenPGP.Util |
@@ -39,9 +40,11 @@ import Data.Word | |||
39 | 40 | ||
40 | data GnuPGAgent = GnuPGAgent { agentHandle :: Handle } | 41 | data GnuPGAgent = GnuPGAgent { agentHandle :: Handle } |
41 | 42 | ||
43 | session :: IO (Maybe GnuPGAgent) | ||
42 | session = do | 44 | session = do |
43 | envhomedir Nothing gpgHomeSpec >>= \case | 45 | envhomedir Nothing gpgHomeSpec >>= \case |
44 | Just gpghome -> do | 46 | Just gpghome -> do |
47 | handleIO_ (hPutStrLn stderr "Failed to connect to gpg-agent." >> return Nothing) $ do | ||
45 | sock <- socket AF_UNIX Stream defaultProtocol | 48 | sock <- socket AF_UNIX Stream defaultProtocol |
46 | connect sock (SockAddrUnix (gpghome ++ "/S.gpg-agent")) | 49 | connect sock (SockAddrUnix (gpghome ++ "/S.gpg-agent")) |
47 | agent <- socketToHandle sock ReadWriteMode | 50 | agent <- socketToHandle sock ReadWriteMode |