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 { ...@@ -438,7 +438,12 @@ export class AppComponent implements OnInit, OnDestroy, Observer {
if (result.emptySession) { if (result.emptySession) {
this.doEmptySession(); 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 { ...@@ -454,8 +454,8 @@ export class FormulaireService extends Observable {
* @param f fichier session * @param f fichier session
* @param formInfos infos sur les modules de calcul @see DialogLoadSessionComponent.calculators * @param formInfos infos sur les modules de calcul @see DialogLoadSessionComponent.calculators
*/ */
public loadSession(f: File, formInfos: any[]) { public loadSession(f: File, formInfos: any[]): Promise<any> {
this.readSingleFile(f).then(s => { return this.readSingleFile(f).then(s => {
const uids: string[] = []; const uids: string[] = [];
formInfos.forEach((fi) => { formInfos.forEach((fi) => {
if (fi.selected) { if (fi.selected) {
...@@ -472,6 +472,7 @@ export class FormulaireService extends Observable { ...@@ -472,6 +472,7 @@ export class FormulaireService extends Observable {
this.createFormulaire(nn.nub.calcType, nn.nub, title); this.createFormulaire(nn.nub.calcType, nn.nub, title);
}); });
}).catch(err => { }).catch(err => {
// forward errors to caller, to avoid "Uncaught (in promise)…"
throw err; throw err;
}); });
} }
......
...@@ -20,7 +20,7 @@ export class NotificationsService { ...@@ -20,7 +20,7 @@ export class NotificationsService {
} }
/** Push a notification and display it as soon as possible */ /** 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({ this.notifications.push({
message: message, message: message,
duration: duration, duration: duration,
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"ERROR_INTERVAL_OUTSIDE": "Interval: value %value% is outside of %interval", "ERROR_INTERVAL_OUTSIDE": "Interval: value %value% is outside of %interval",
"ERROR_INTERVAL_UNDEF": "Interval: invalid 'undefined' value", "ERROR_INTERVAL_UNDEF": "Interval: invalid 'undefined' value",
"ERROR_INVALID_AT_POSITION": "Position %s:", "ERROR_INVALID_AT_POSITION": "Position %s:",
"ERROR_LOADING_SESSION": "Unable to load session",
"ERROR_MINMAXSTEP_MAX": "Value is not in ]%s,%s]", "ERROR_MINMAXSTEP_MAX": "Value is not in ]%s,%s]",
"ERROR_MINMAXSTEP_MIN": "Value is not in [%s,%s[", "ERROR_MINMAXSTEP_MIN": "Value is not in [%s,%s[",
"ERROR_MINMAXSTEP_STEP": "Value is not in %s", "ERROR_MINMAXSTEP_STEP": "Value is not in %s",
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"ERROR_INTERVAL_OUTSIDE": "Interval&nbsp;: la valeur %value% est hors de l'intervalle %interval", "ERROR_INTERVAL_OUTSIDE": "Interval&nbsp;: la valeur %value% est hors de l'intervalle %interval",
"ERROR_INTERVAL_UNDEF": "Interval&nbsp;: valeur 'undefined' incorrecte", "ERROR_INTERVAL_UNDEF": "Interval&nbsp;: valeur 'undefined' incorrecte",
"ERROR_INVALID_AT_POSITION": "Position %s :", "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_MAX": "La valeur n'est pas dans ]%s,%s]",
"ERROR_MINMAXSTEP_MIN": "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", "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