specific error classes makes sense when you have errors that can only happen in one method. E.g. invalidAttributesError() should only be available after submitAttributes(), i.e. we wrap that utility method in SignUpSubmitAttributesError which is emitted from submitAttributes()
this has worked well so far: every method we have has method-specific errors, so there has always been a reason to create dedicated error classes
however, for MFA this is not the case. Only submitChallenge() has a specific error (invalid challenge), all the rest doesn't.
however, we should still introduce specific MFA error classes anyway, because without it it would either be a breaking change when we add it (e.g. requestChallenge() will not longer emit MFAError, but now emit MFASubmitChallengeError), or developers are going to need to check for both error classes (e.g. if error is MFAError || error is MFASubmitChallengeError)
invalidAttributesError()
should only be available aftersubmitAttributes()
, i.e. we wrap that utility method inSignUpSubmitAttributesError
which is emitted fromsubmitAttributes()
submitChallenge()
has a specific error (invalid challenge), all the rest doesn't.requestChallenge()
will not longer emitMFAError
, but now emitMFASubmitChallengeError
), or developers are going to need to check for both error classes (e.g.if error is MFAError || error is MFASubmitChallengeError
)