JHershey69 / OpenWeatherOneCall

Open Weather One Call library to gather current, hourly (48), and 7 day weather for your current location
GNU General Public License v3.0
38 stars 11 forks source link

Provide a bit more detail on how to handle errors #45

Closed k5map closed 2 years ago

k5map commented 2 years ago

First of all, GREAT OpenWeather library...

I'm struggling to understand how to capture errors when I execute the OWOC.parseWeather() function. I successfully recreated the error provided in the documentation. But I want to confirm if I want to capture any errors after the initial setup/call, I include the same if statement in the doc after any parseWeather() functions, correct?

JHershey69 commented 2 years ago
Yes, you have it right. int errorM;errorM = “Whatever function you are calling” ß OWOC.setOpenWeatherKey(ONECALLKEY) for example Then use the if (errorM) routine. Let me know how you do with that. I’m glad you like the library. Jessica   Sent from Mail for Windows From: MikeSent: Sunday, July 24, 2022 2:12 AMTo: JHershey69/OpenWeatherOneCallCc: SubscribedSubject: [JHershey69/OpenWeatherOneCall] Provide a bit more detail on how to handle errors (Issue #45) First of all, GREAT OpenWeather library...I'm struggling to understand how to capture errors when I execute the OWOC.parseWeather() function. I successfully recreated the error provided in the documentation But I want to confirm if I want to capture any errors after the initial setup/call, I include the same if statement in the doc after any parseWeather() functions, correct?—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>  This email has been checked for viruses by Avast antivirus software. www.avast.com
k5map commented 2 years ago

@JHershey69

Ok I was able to get the error handling setup successfully where I call the function parseWeather but only after I worked out the issue of "message" being a char array. At first I tried to declare it a String but the IDE would not compile until I changed it to a char.

If you make any future changes/updates to the code, I would request to have the function getErrorsMsgs output a String (to eliminate having to call the function strcpy to get the error message into a String var.

Thanks again for the API and prompt reply to my post.

JHershey69 commented 2 years ago

If you look at errormsg.h you will see how the errors messages are formatted as const char. Strings are bulky and I tried to avoid them as much as possible. :)