Typoskript/Winkel try catch ein Fehler im try-block nicht catch-block

Ich bin mit Winkel-und Maschinenschrift.
Ich habe verwendet, versuchen Sie, catch-Konstrukt zur Fehlerbehandlung im Falle von API-Aufruf.
Wenn irgendwelche Fehler tritt im try-block es ist einfach NICHT catch-block.
App beendet sich es nur.

Habe ich versucht, mit throw als gut.
Hier ist ein Beispiel-code-snippet,

try {

  this.api.getAPI(Id).subscribe( //this.api is my api service and getAPI is present there
    (data: any) => {
      if (data == null) {
        throw 'Empty response';
      }
    },
    (error: HttpErrorResponse) => {
      console.log(error);
    };

} catch(e) {
  console.log(e); 
}

in einigen Fällen 'Daten' aus der API-Rückgabe 'null',
aber werfen ist nicht catch-block
AUCH versucht, ohne werfen, es gibt null Fehler für 'Daten' ... in diesem Fall auch nicht zu catch-block.

InformationsquelleAutor Nils | 2018-05-23
Schreibe einen Kommentar