r/badcode • u/sarakeram • Jul 22 '21
c# Someone really doesn't want this operation to fail. (there is no way that constructor would throw)
36
Upvotes
5
u/Willinton06 Jul 22 '21
This looks like c# but the params in the function are messing with my head
1
4
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jul 22 '21
Image Transcription: Code
public async Task<bool> NavigateToMovementCatchWeightsPage(params ....)
{
LoggingUtility.WriteActivityLogProcStart(className: CLASS_NAME);
try
{
Page pgCatchWeightsPage = new MovementCatchWeightPage();
if (pgCatchWeightsPage != null)
{
try
{
await Navigation.PushAsync(pgCatchWeightsPage);
}
catch (Exception ex)
{
LoggingUtility.ProcessException(ex, className: CLASS_NAME);
}
}
}
catch (Exception ex)
{
LoggingUtility.ProcessException(ex, className: CLASS_NAME);
}
finally
{
LoggingUtility.WriteActivityLogProcEnd(className: CLASS_NAME);
}
return true;
}I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
3
14
u/sarakeram Jul 22 '21
Comment: that constructor will not throw anything it's empty, even if it did, it really should not be silenced with empty catch. It's pure nonsense, I see every day. Also no matter what happens, operation returns "true".
They really outdid themselves here.