Angular Electron - Uncaught Exception

70 Views Asked by At

So I have this Angular app that I've made for my company with a working web version but they've asked me to make it into a .exe app so I've searched for solutions. That's where I learned about Electron, I installed it and managed to make a .exe of my application but the problem is that there was a part of my code that's not working and it's about a try...catch block that's not working, wether it is here or not I would get a "Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'y')".

const Client: Client = this.model.LatLongFromFormContent;
    let convertedAddress = await this.provider.search({query: ""+Client.Adresse+","+Client.CP+" "+Client.Ville});
    let latLngClient: any;
    try{
      latLngClient = L.latLng(convertedAddress[0].y, convertedAddress[0].x);
      let closestAgency: string = "";
      let distanceClosestAgency: number = 500;

      AgencyList.forEach(async agency =>{
          let distance = (latLngClient.distanceTo(L.latLng(agency.GPS[0], agency.GPS[1]))/1000);
          if (distance <= distanceClosestAgency){
            closestAgency = agency.Num_agence+" - "+agency.VILLE;
            distanceClosestAgency = distance
          }
      })
      this.model.distanceToClosestAgency = Math.round(distanceClosestAgency *100)/100;
      this.model.closestAgency = closestAgency;
    }catch (error){
      this.model.formGroup.controls['CP'].setErrors({'incorrect': true})
      this.model.formGroup.controls['Ville'].setErrors({'incorrect':true})
    }

If the error is caught, we're supposed to have a message appear on screen when a div is set to visible

<div *ngIf="model.formGroup.controls['CP'].invalid && model.formGroup.controls['Ville'].invalid && model.formGroup.controls['CP'].value != null" class="mt-2 alert alert-danger">
      Vérifiez que le code postal et la ville correspondent bien.
    </div>

but this is not happening, instead I have the error I pointed out earlier...

Any help would be appreciated

0

There are 0 best solutions below