nonNullAble<T> method
T
nonNullAble<T>(
- T? argument
Makes sure that the CarpApp or CarpUser is configured, by throwing a CarpServiceException if they are null. Otherwise, returns the non-null value.
Implementation
T nonNullAble<T>(T? argument) {
if (argument == null && argument is CarpApp) {
throw CarpServiceException(
message:
"CARP Service not initialized. Call 'CarpAuthService().configure()' first.");
} else if (argument == null && argument is CarpUser) {
throw CarpServiceException(
message:
"CARP User not authenticated. Call 'CarpAuthService().authenticate()' first.");
} else {
return argument!;
}
}