public BuildErrorLog(Exception e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            _message    = string.IsNullOrEmpty(e.Message) ? Common.SR.InternalError : e.Message;
            _type       = e.GetType().FullName;
            _source     = e.Source;
            _helpLink   = e.HelpLink;
            _stackTrace = e.StackTrace;

            if (e is ResolveReferenceException)
            {
                _hint = SR.ResolveReferenceErrorHint;
            }
            else if (e is NativeCodeException)
            {
                _hint = SR.NativeCodeErrorHint;
            }
            else if (e is InvalidOperationException ||
                     e is NotImplementedException ||
                     e is NullReferenceException ||
                     e is ArgumentException)
            {
                _message = Common.SR.InternalError;
            }

            if (e.InnerException != null)
            {
                _inner = new BuildErrorLog(e.InnerException);
            }
        }
        private void PrintException(StringBuilder sb, BuildErrorLog e)
        {
            sb.Append("--- Exception ----------------------------------------------------------").AppendLine();

            sb.AppendFormat("Message: {0}", e.Message).AppendLine();

            if (!string.IsNullOrEmpty(e.Type))
            {
                sb.AppendFormat("Type: {0}", e.Type).AppendLine();
            }

            if (!string.IsNullOrEmpty(e.Source))
            {
                sb.AppendFormat("Source: {0}", e.Source).AppendLine();
            }

            if (!string.IsNullOrEmpty(e.Hint))
            {
                sb.AppendFormat("Hint: {0}", e.Hint).AppendLine();
            }

            if (!string.IsNullOrEmpty(e.HelpLink))
            {
                sb.AppendFormat("Help link: {0}", e.HelpLink).AppendLine();
            }

            if (e.Inner != null)
            {
                PrintException(sb, e.Inner);
            }
        }
        internal void Read(Blob blob, ref int pos)
        {
            _message    = blob.ReadLengthPrefixedString(ref pos, Encoding.UTF8);
            _type       = blob.ReadLengthPrefixedString(ref pos, Encoding.UTF8);
            _source     = blob.ReadLengthPrefixedString(ref pos, Encoding.UTF8);
            _hint       = blob.ReadLengthPrefixedString(ref pos, Encoding.UTF8);
            _helpLink   = blob.ReadLengthPrefixedString(ref pos, Encoding.UTF8);
            _stackTrace = blob.ReadLengthPrefixedString(ref pos, Encoding.UTF8);

            if (blob.ReadBoolean(ref pos))
            {
                _inner = new BuildErrorLog();
                _inner.Read(blob, ref pos);
            }
        }