darwinex / dwxconnect

Seamlessly link any Trading Strategy in ANY programming language to Darwinex liquidity via MetaTrader 4 or 5. DWX Connect is your very own, fully customizable Trading API!
BSD 3-Clause "New" or "Revised" License
158 stars 84 forks source link

Updated Helpers.cs tryReadFile method so that it handles exceptions that may happen, without crashing the program. #44

Open spliffli opened 3 months ago

spliffli commented 3 months ago

Updated the tryReadFile method so that it handles some exceptions and I ran into all 3 of these exceptions while building upon this code in another project and thought it might be worth contributing.

Because the tryReadFile method frequently gets called from a loop for checking for a file at a given path, returning an empty string after handling each exception means it will just try again at the next loop and operate smoothly without crashing the program.

spliffli commented 3 months ago

By the way, sorry for doing so many commits after I opened the pull request. It's because as I was editing the file in this repo directly on github, I improvised a new method to get the file name from a filepath so it can write that to the console when there's an exception, and I forgot to add the var keyword.

Feel free to edit the Console.WriteLine statements since I know you use a helper method called print for writing to the console.

Also, if you want me to instead open a different pull request on the developer branch instead of the main branch I can do that.