Let's say I have the following block:
protected override void ProcessRecord()
{
try
{
// code that throws
}
catch (System.Exception exception)
{
// handle error
}
}
How can I properly write the exception? Using WriteError
? Is the following a good approach?
WriteError(new ErrorRecord(exception, exception.Source, ErrorCategory.InvalidOperation, exception));
If so, should I be using ErrorRecord
?