UpiException.fromException constructor
UpiException.fromException(
- PlatformException exception
Factory method to create an instance of UpiException from a PlatformException.
Parameters:
exception
: The platform exception to convert to a UPI exception.
Implementation
factory UpiException.fromException(PlatformException exception) {
UpiExceptionType type;
switch (exception.code) {
case 'Cancelled':
type = UpiExceptionType.cancelledException;
break;
case 'Failure':
type = UpiExceptionType.failedException;
break;
case 'Submitted':
type = UpiExceptionType.submittedException;
break;
case 'App Not Found Exception':
type = UpiExceptionType.appNotFoundException;
break;
default:
type = UpiExceptionType.unknownException;
break;
}
return UpiException(
type: type,
message: exception.message,
details: exception.details,
stacktrace: exception.stacktrace,
);
}