diff --git a/src/Microsoft.ML.TensorFlow/TensorflowUtils.cs b/src/Microsoft.ML.TensorFlow/TensorflowUtils.cs index cae9f3b379..49cb34040e 100644 --- a/src/Microsoft.ML.TensorFlow/TensorflowUtils.cs +++ b/src/Microsoft.ML.TensorFlow/TensorflowUtils.cs @@ -3,7 +3,6 @@ // See the LICENSE file in the project root for more information. using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.AccessControl; @@ -488,9 +487,26 @@ public Tensor[] Run() unsafe { - c_api.TF_SessionRun(_session, null, _inputs, _inputValues, - _inputs.Length, _outputs, _outputValues, _outputValues.Length, _operations, - _operations.Length, IntPtr.Zero, _status); + try + { + c_api.TF_SessionRun(_session, null, _inputs, _inputValues, + _inputs.Length, _outputs, _outputValues, _outputValues.Length, _operations, + _operations.Length, IntPtr.Zero, _status); + } + catch (Exception ex) + { + try + { + _status.Check(throwException: true); + } + catch (Exception statusException) + { + throw new AggregateException(statusException, ex); + } + + // _status didn't provide more information, so just rethrow the original exception + throw; + } } _status.Check(true);