File tree Expand file tree Collapse file tree
src/main/java/com/google/firebase/fpnv Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616
1717package com .google .firebase .fpnv ;
1818
19+ import com .google .firebase .ErrorCode ;
20+ import com .google .firebase .FirebaseException ;
21+
1922/**
2023 * Generic exception related to Firebase Phone Number Verification.
2124 * Check the error code and message for more
2225 * details.
2326 */
24- public class FirebasePnvException extends Exception {
27+ public class FirebasePnvException extends FirebaseException {
2528 private final FirebasePnvErrorCode errorCode ;
2629
2730 /**
@@ -37,7 +40,7 @@ public FirebasePnvException(
3740 String message ,
3841 Throwable cause
3942 ) {
40- super (message , cause );
43+ super (mapToFirebaseError ( errorCode ), message , cause );
4144 this .errorCode = errorCode ;
4245 }
4346
@@ -57,4 +60,23 @@ public FirebasePnvException(
5760 public FirebasePnvErrorCode getFpnvErrorCode () {
5861 return errorCode ;
5962 }
63+
64+ private static ErrorCode mapToFirebaseError (FirebasePnvErrorCode code ) {
65+ if (code == null ) {
66+ return ErrorCode .INTERNAL ;
67+ }
68+ switch (code ) {
69+ case INVALID_ARGUMENT :
70+ return ErrorCode .INVALID_ARGUMENT ;
71+ case TOKEN_EXPIRED :
72+ case INVALID_TOKEN :
73+ return ErrorCode .UNAUTHENTICATED ;
74+ case SERVICE_ERROR :
75+ return ErrorCode .UNAVAILABLE ;
76+ case INTERNAL_ERROR :
77+ default :
78+ return ErrorCode .INTERNAL ;
79+ }
80+ }
6081}
82+
You can’t perform that action at this time.
0 commit comments