public static string ToErrorCode(this Exception ex) { var hasErrorCode = ex as IHasErrorCode; return hasErrorCode?.ErrorCode ?? ex.GetType().Name; }