I have been using basic c# mainly for Unity3d but recently started picking it up bit more. While reading about idiomatic handling exceptions I came across exception serialization. I am trying to figure out why should I be serializing them.
Here is sample code from another thread.
using System;
using System.Runtime.Serialization;
[Serializable]
public class MyException : Exception
{
// Constructors
public MyException(string message)
: base(message)
{ }
// Ensure Exception is Serializable
protected MyException(SerializationInfo info, StreamingContext ctxt)
: base(info, ctxt)
{ }
}
I can't see how it could be useful to serialize exceptions. When and why does it make sense to do so?