Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 用镜头捕捉多个异常_Amazon Web Services_Haskell_Exception_Haskell Lens - Fatal编程技术网

Amazon web services 用镜头捕捉多个异常

Amazon web services 用镜头捕捉多个异常,amazon-web-services,haskell,exception,haskell-lens,Amazon Web Services,Haskell,Exception,Haskell Lens,我使用Lens和Amazonka来处理错误,但我很难处理错误: doSignup e p = (AWS.send $ AWS.signUp "secret" e p) $> Right () & catching_ AWS._UsernameExistsException (return $ Left AlreadyExistingEmail) & catching_ AWS._InvalidPasswordException (

我使用
Lens
Amazonka
来处理错误,但我很难处理错误:

doSignup e p = (AWS.send $ AWS.signUp "secret" e p)
    $> Right ()
    & catching_ AWS._UsernameExistsException (return $ Left AlreadyExistingEmail)
    & catching_ AWS._InvalidPasswordException (return $ Left WeakPassword)
    & catching  AWS._SertviceError (return . UnknownSignUpError)

data SignUpError where
  AlreadyExistingEmail ::                          SignUpError
  NotAnEmail           ::                          SignUpError
  WeakPassword         ::                          SignUpError
  UnknownSignUpError   :: forall a. Show a => a -> SignUpError
我努力保持一致的捕获行为,当抛出
\u用户名existsexception
时,我得到了一个
左弱密码

它变得更奇怪,因为当我删除
WeakPassword
行时,它就工作了

虽然我得到了正确的错误(只保留最后一行):

我曾尝试使用
捕捉
,但
处理程序
需要
可打印
镜头,但事实并非如此


我怎样才能有一种“类似模式匹配”的方法来处理异常?提前感谢。

事实上,使用了
控件.Lens.catching
而不是
Network.AWS.Prelude.catching
,这扰乱了异常处理。

这似乎非常令人惊讶。能否显示引发异常的代码?也许你没有得到你认为的例外。
       expected: Right ()
        but got: Left UnknownSignUpError ServiceError' {_serviceAbbrev = Abbrev "CognitoIdentityProvider", _serviceStatus = Status {statusCode = 400, statusMessage = "Bad Request"}, _serviceHeaders = [("Date","Tue, 06 Oct 2020 05:38:56 GMT"),("Content-Type","application/x-amz-json-1.1"),("Content-Length","96"),("Connection","keep-alive"),("x-amzn-RequestId","b09210a3-41ed-46ee-af4f-46db58b98695"),("x-amzn-ErrorType","UsernameExistsException:"),("x-amzn-ErrorMessage","An account with the given email already exists.")], _serviceCode = ErrorCode "UsernameExists", _serviceMessage = Just (ErrorMessage "An account with the given email already exists."), _serviceRequestId = Just (RequestId "b09210a3-41ed-46ee-af4f-46db58b98695")}