我试图弄清楚抛出异常的位置。这是我在Haskell中进行异常处理的第一次经历。我试图在远程主机上调用XML-RPC函数,使用https:
进行访问ghci> import Network.XmlRpc.Client
ghci> import Network.XmlRpc.Internals
ghci> remote "https://rpc.ote.gandi.net/xmlrpc/" "domain.count" (ValueString "01234567890ABCDEF")
*** Exception: user error (https not supported)
为了弄清楚我是否忘记在某个软件包中启用SSL支持,或者它是否有所不同,我想知道哪个软件包会引发异常。
我首先按照GHC docs中的说明开始,但它没有按预期进行:
ghci> :set -fbreak-on-exception
ghci> :trace remote "https://rpc.ote.gandi.net/xmlrpc/" "domain.count" (ValueString "01234567890ABCDEF")
Stopped at <exception thrown>
_exception :: e = _
ghci> :hist
Empty history. Perhaps you forgot to use :trace?
所有相关的软件包都应该使用--enable-library-profiling
进行编译。
如何找到例外?
答案 0 :(得分:5)
你无法获得任何好信息的原因是:trace
无法进入库代码 - 我们需要解释我们想要跟踪的任何代码。是否使用分析编译是无关紧要的。在安装了一些依赖项后,我这样做是为了获得更多信息:
% cabal unpack haxr
% cd haxr-3000.8.5
% ghci Network/XmlRpc/Client.hs -XOverlappingInstances -XTypeSynonymInstances -XFlexibleInstances -XTemplateHaskell
*Network.XmlRpc.Client> :set -fbreak-on-exception
*Network.XmlRpc.Client> :trace remote "https://rpc.ote.gandi.net/xmlrpc/" "domain.count" (ValueString "01234567890ABCDEF")
Stopped at <exception thrown>
_exception :: e = _
[<exception thrown>] *Network.XmlRpc.Client> :hist
-1 : authHdr (Network/XmlRpc/Client.hs:169:27-33)
-2 : request:parseUserInfo (Network/XmlRpc/Client.hs:161:34-40)
-3 : request:parseUserInfo (Network/XmlRpc/Client.hs:161:31-73)
-4 : request:parseUserInfo:(...) (Network/XmlRpc/Client.hs:159:55-70)
-5 : request:parseUserInfo:(...) (Network/XmlRpc/Client.hs:159:39-51)
-6 : request:parseUserInfo:(...) (Network/XmlRpc/Client.hs:159:39-70)
-7 : request:parseUserInfo (Network/XmlRpc/Client.hs:160:34-39)
-8 : request:parseUserInfo (Network/XmlRpc/Client.hs:160:31-64)
-9 : request:parseUserInfo (Network/XmlRpc/Client.hs:(160,29)-(161,74))
-10 : request:parseUserInfo (Network/XmlRpc/Client.hs:(159,5)-(161,74))
-11 : authHdr (Network/XmlRpc/Client.hs:(169,1)-(175,60))
-12 : request:headers (Network/XmlRpc/Client.hs:158:33-47)
-13 : request:headers (Network/XmlRpc/Client.hs:158:33-63)
-14 : request:headers (Network/XmlRpc/Client.hs:158:33-70)
-15 : request:headers (Network/XmlRpc/Client.hs:158:20-71)
-16 : request:headers (Network/XmlRpc/Client.hs:157:16-65)
-17 : request:headers (Network/XmlRpc/Client.hs:156:16-47)
-18 : request:headers (Network/XmlRpc/Client.hs:155:16-44)
-19 : request:headers (Network/XmlRpc/Client.hs:(155,15)-(158,71))
-20 : request (Network/XmlRpc/Client.hs:(149,28)-(152,54))
...
希望这能让你开始。您可能会发现这会导致您进入另一个库边界 - 如果是这样,您将需要解压缩并解释该库以进行更深入的处理。祝你好运!