Skip to content
Snippets Groups Projects
Commit 9b2549e5 authored by mathias.chouet's avatar mathias.chouet
Browse files

Fix #202

parent 80fb55c2
No related branches found
No related tags found
No related merge requests found
......@@ -438,7 +438,12 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
if (result.emptySession) {
this.doEmptySession();
}
this.formulaireService.loadSession(result.file, result.calculators);
this.formulaireService.loadSession(result.file, result.calculators).catch((err) => {
this.notificationsService.notify(this.intlService.localizeText("ERROR_LOADING_SESSION"));
console.error("error loading session - ", err);
// rollback to ensure session is clean
this.doEmptySession();
});
}
});
}
......
......@@ -454,8 +454,8 @@ export class FormulaireService extends Observable {
* @param f fichier session
* @param formInfos infos sur les modules de calcul @see DialogLoadSessionComponent.calculators
*/
public loadSession(f: File, formInfos: any[]) {
this.readSingleFile(f).then(s => {
public loadSession(f: File, formInfos: any[]): Promise<any> {
return this.readSingleFile(f).then(s => {
const uids: string[] = [];
formInfos.forEach((fi) => {
if (fi.selected) {
......@@ -472,6 +472,7 @@ export class FormulaireService extends Observable {
this.createFormulaire(nn.nub.calcType, nn.nub, title);
});
}).catch(err => {
// forward errors to caller, to avoid "Uncaught (in promise)…"
throw err;
});
}
......
......@@ -20,7 +20,7 @@ export class NotificationsService {
}
/** Push a notification and display it as soon as possible */
public notify(message: string, duration: number, action: string = "OK") {
public notify(message: string, duration: number = 2000, action: string = "OK") {
this.notifications.push({
message: message,
duration: duration,
......
......@@ -10,6 +10,7 @@
"ERROR_INTERVAL_OUTSIDE": "Interval: value %value% is outside of %interval",
"ERROR_INTERVAL_UNDEF": "Interval: invalid 'undefined' value",
"ERROR_INVALID_AT_POSITION": "Position %s:",
"ERROR_LOADING_SESSION": "Unable to load session",
"ERROR_MINMAXSTEP_MAX": "Value is not in ]%s,%s]",
"ERROR_MINMAXSTEP_MIN": "Value is not in [%s,%s[",
"ERROR_MINMAXSTEP_STEP": "Value is not in %s",
......
......@@ -10,6 +10,7 @@
"ERROR_INTERVAL_OUTSIDE": "Interval&nbsp;: la valeur %value% est hors de l'intervalle %interval",
"ERROR_INTERVAL_UNDEF": "Interval&nbsp;: valeur 'undefined' incorrecte",
"ERROR_INVALID_AT_POSITION": "Position %s :",
"ERROR_LOADING_SESSION": "Impossible de charger la session",
"ERROR_MINMAXSTEP_MAX": "La valeur n'est pas dans ]%s,%s]",
"ERROR_MINMAXSTEP_MIN": "La valeur n'est pas dans [%s,%s[",
"ERROR_MINMAXSTEP_STEP": "La valeur n'est pas dans %s",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment