Closed vanceanderson41 closed 3 years ago
Hi @vanceanderson41 ,
AmplifyException
(and category exceptions that extend it such as AuthException
on Android platform currently has the following properties:
message
- this is the message specifying what type of error was encountered and should be treated as the error message itselfcause
- any Throwable
instance that may contain more specific information as to why this AmplifyException
was thrownrecoverySuggestion
- suggestion to recover from this error and/or prevent itIn all the above API usage scenarios, the cause fields are of types that ARE NOT those that extend
AuthException
. For example, one might expect, in the supplied scenario, that the cause field supplied with anAuthException
is of the typeAuthException.CodeMismatchException
but it is insteadAmazonServiceException.CodeMismatchException
.
This was by design. We wanted the subclasses of AuthException
(e.g. AuthException#CodeMismatchException
) to be the directly surfaced by the error callbacks to immediately make it obvious what type of error is being encountered rather than hide it under the cause
field.
However, I do agree that "An error occurred confirming password recovery code" isn't exactly a very helpful error message. I will bring this issue up with the team to see how we can improve the quality of existing error messages to be more informative.
Hello @vanceanderson41 , Thanks for reporting the issue. Our team is working on this feature right now. Will get back to you once the feature is released.
I still see this issue. Which error message is intended here:
Hi @vancefunraise - closed issues have limited visibility for the team, can you please open a new issue?
AWSCognitoAuthPlugin
and am unable to easily get useful error messages from the root error objects returned byAmplify
with which to to surface to my users.1.6.8
In the case of 4), 1) The type supplied to
onError
is explicitly aThrowable
but seemingly reliably cast as anAmplifyException.AuthException
(As clearly seen in the logs as the throwable type) e.g. in Kotlin, this works in every test I have performed:2)
it
as anAmplifyException
has publicString
messages associated with it which are the following:message
,localizedMessage
,recoverySuggestion
(and no others) 2a) In the case ofRxAmplify.Auth.confirmResetPassword(...)
, that errors for something like aCodeMismatchException
, those values are:1) The above are the error strings supplied with the provided
AuthException
AND they are generic/less than explicit and user friendly than anything we might surface to users interacting with this API. 2) The underlyingcause (Throwable)
field exposed by theAuthException
object when returned from all above cases outlined in the above code snippets, DO have the types of strings I would want to supply to my users viaerrorMessage
field.e.g.
Invalid verification code provided, please try again.
The
cause
field's values also match the supplied values for the same scenarios on the ios-amplify-sdk root error objects produced here: https://github.com/aws-amplify/aws-sdk-ios However: In all the above API usage scenarios, thecause
fields are of types that ARE NOT those that extendAuthException
. For example, one might expect, in the supplied scenario, that thecause
field supplied with anAuthException
is of the typeAuthException.CodeMismatchException
but it is insteadAmazonServiceException.CodeMismatchException
. (TheAuthException
derived classes defined in theAuthException
class are not used as thecause
)Further, those
cause
fields are of typeThrowable
who use the constructor with only thecause
supplied and as such whosemessage
fields contain the wholetoString()
of theThrowable
passed to the respective constructor resulting in something like:Invalid verification code provided, please try again. (Service: AmazonCognitoIdentityProvider; Status Code: 400; Error Code: CodeMismatchException; Request ID: ae617a3b-cf3b-4568-ad23-79359efac707)
instead ofInvalid verification code provided, please try again.
as themessage
field contentTo clarify further: 1)
AuthException
fields do not supply representative strings beyondmessage
,localizedMessage
when maybe they should supply something like anerrorMessage
explicitly that is more user friendly like iOS SDKs do 2) Theircause
fields in the outlined scenarios provide better error messages but are not obviously generically typed(AmplifyException children vs AmazonServiceException children
as a parent)TL;DR: What is the best way to surface intended/user friendly
Amplify
error messages to my users?