You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're currently facing issues with querying multiple results and reading each of them unbuffered.
After investigating the Dapper source code I think we may have some exception that is being hidden by Dapper. Our stack trace reveals an exception being thrown in OnAfterGridAsync which is being called in a finally block. I understand that this block is necessary.
asyncTaskMain(){awaitforeach(varrecordinReadUnbufferedAsync()){// ...}}privateasyncTaskOnAfterGridAsync(){awaitTask.Yield();thrownewInvalidOperationException("OnAfterGridAsync");}privateasyncTask<bool>ReadAsync(){awaitTask.Yield();thrownewInvalidOperationException("ReadAsync");// this exception will be hidden by the other}privatestringConvertTo(){return"Record";}publicasyncIAsyncEnumerable<string>ReadUnbufferedAsync(){try{while(awaitReadAsync()){yieldreturnConvertTo();}}finally{awaitOnAfterGridAsync();}}
However, wouldn't it be possible to apply refactoring to properly propagate exceptions to the call-site?
asyncTaskMain(){awaitforeach(varrecordinReadUnbufferedAsync()){// ...}}privateasyncTaskOnAfterGridAsync(){awaitTask.Yield();thrownewInvalidOperationException("OnAfterGridAsync");}privateasyncTask<bool>ReadAsync(){awaitTask.Yield();thrownewInvalidOperationException("ReadAsync");}privatestringConvertTo(){return"Record";}publicasyncIAsyncEnumerable<string>ReadUnbufferedAsync(){ExceptionDispatchInfo?exceptionCaught=null;try{while(true){stringrecord;try{varhasNext=awaitReadAsync();if(!hasNext){break;}record=ConvertTo();}catch(Exceptionex){exceptionCaught=ExceptionDispatchInfo.Capture(ex);break;}yieldreturnrecord;}}finally{try{awaitOnAfterGridAsync();}catch{if(exceptionCaught==null){throw;}// else swallow this exception and propagate the other}exceptionCaught?.Throw();}}
The text was updated successfully, but these errors were encountered:
We're currently facing issues with querying multiple results and reading each of them unbuffered.
After investigating the Dapper source code I think we may have some exception that is being hidden by Dapper. Our stack trace reveals an exception being thrown in
OnAfterGridAsync
which is being called in afinally
block. I understand that this block is necessary.However, wouldn't it be possible to apply refactoring to properly propagate exceptions to the call-site?
The text was updated successfully, but these errors were encountered: