PackRuble / weather_pack

The project is designed to obtain weather via the OpenWeatherMap API. With handy features. :)
https://pub.dev/packages/weather_pack
MIT License
4 stars 3 forks source link

Add error handling to readme #4

Closed PackRuble closed 7 months ago

PackRuble commented 7 months ago

Implemented in version v1.1.0

Each of the methods in the WeatherService and GeocodingService services can throw an OwmApiException exception. You can process them as follows:

void exceptionHandling() async {
  final wService = WeatherService('bRoKen_aPi');

  WeatherCurrent? current;
  try {
    current =
        await wService.currentWeatherByLocation(latitude: 1, longitude: 1);
  } on OwmApiException catch (e, s) {
    print(e.code);
    print(e.message);
    print(s);
  }
}