Skip to content

Commit

Permalink
chore(app): more specific error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Frost committed Jul 25, 2022
1 parent 3a3dab9 commit 84efd1f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
}
}
},
"err_could_not_retrieve_access_token": "An unexpected error occurred while retrieving the access token",
"err_fetch_user_data_failed": "An unexpected error occurred while fetching your genomic data",
"err_generic": "Error!",

Expand Down
34 changes: 18 additions & 16 deletions app/lib/login/pages/cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ class LoginPageCubit extends Cubit<LoginPageState> {
Future<void> signInAndLoadUserData(BuildContext context, Lab lab) async {
emit(LoginPageState.loadingUserData());

// authenticate
String? token;
try {
// authenticate
String token;
try {
token = await _getAccessToken(
context,
authUrl: lab.authUrl,
tokenUrl: lab.tokenUrl,
);
} on PlatformException catch (e) {
if (e.code == 'CANCELED') {
revertToInitialState();
} else {
emit(LoginPageState.error(context.l10n.err_generic));
}
return;
}
token = await _getAccessToken(
context,
authUrl: lab.authUrl,
tokenUrl: lab.tokenUrl,
);
} on PlatformException catch (e) {
if (e.code == 'CANCELED') revertToInitialState();
}

if (token == null) {
emit(LoginPageState.error(
context.l10n.err_could_not_retrieve_access_token,
));
return;
}

try {
// get data
await fetchAndSaveDiplotypes(token, lab.endpoint);
await fetchAndSaveLookups();
Expand Down

0 comments on commit 84efd1f

Please sign in to comment.