8

例外がスローされる場所を把握しようとしています。これらは、Haskell での例外処理に関する私の最初の経験です。https を使用してアクセスするリモート ホストで XML-RPC 関数を呼び出そうとしています。

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

例外を見つける方法は?

4

1 に答える 1

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))
    ...

うまくいけば、それで始められます。これにより、別のライブラリ境界につながることがわかる場合があります。その場合は、そのライブラリを解凍して解釈し、さらに深くする必要があります。幸運を!

于 2012-05-31T18:39:48.457 に答える