public Error(int errorCode, string className, string message, string causeClassName, int? causeErrorCode,
     StackTraceElement[] stackTrace)
 {
     CauseClassName = causeClassName;
     CauseErrorCode = causeErrorCode;
     ClassName = className;
     ErrorCode = errorCode;
     Message = message;
     StackTrace = stackTrace;
 }
 public static void Encode(StackTraceElement stackTraceElement, ClientMessage clientMessage)
 {
     clientMessage.Set(stackTraceElement.ClassName);
     clientMessage.Set(stackTraceElement.MethodName);
     string fileName = stackTraceElement.FileName;
     var fileName_NotNull = fileName != null;
     clientMessage.Set(fileName_NotNull);
     if (fileName_NotNull)
     {
         clientMessage.Set(fileName);
     }
     clientMessage.Set(stackTraceElement.LineNumber);
 }
 public static int CalculateDataSize(StackTraceElement stackTraceElement)
 {
     var dataSize = Bits.IntSizeInBytes;
     dataSize += ParameterUtil.CalculateDataSize(stackTraceElement.ClassName);
     dataSize += ParameterUtil.CalculateDataSize(stackTraceElement.MethodName);
     dataSize += Bits.BooleanSizeInBytes;
     string fileName = stackTraceElement.FileName;
     var fileName_NotNull = fileName != null;
     if (fileName_NotNull)
     {
         dataSize += ParameterUtil.CalculateDataSize(fileName);
     }
     return dataSize;
 }
        public Exception CreateException(int errorCode, string className, string message, StackTraceElement[] stackTrace
            , int? causeErrorCode, string causeClassName)
        {
            Exception cause = null;
            if (causeClassName != null && causeErrorCode.HasValue)
            {
                cause = CreateException(causeErrorCode.Value, null, null);
            }

            var exception = CreateException(errorCode, message, cause);

            return exception;
        }