Exemplo n.º 1
0
 // Remote/client error, or error without explicit exception
 public ErrorLogEntry(LogContext context, string message, string details, ErrorKind kind = ErrorKind.Internal,
                      DateTime?remoteTime = null)
     : base(context)
 {
     Message = message;
     Details = details;
     Kind    = kind;
     if (remoteTime != null)
     {
         this.CreatedOn = remoteTime.Value;
     }
     Exception     = new Exception(message);
     ExceptionType = kind.ToString();
 }
Exemplo n.º 2
0
 public ErrorIn(ErrorKind ek) : base(String.Format("error in parsing: {0}", ek.ToString()))
 {
 }
Exemplo n.º 3
0
        public void Report(ErrorKind level, Cursor cursor, int code, string text)
        {
            Error error = new Error(level, cursor, code, text);

            _lock.Acquire();
            _errors.Add(error);
            _lock.Release();

            // update Failed property that indicates whether one or more errors have occured
            switch (level)
            {
                case ErrorKind.Debug    : break;
                case ErrorKind.Error    : _failed = true; break;
                case ErrorKind.Fatal    : _failed = true; break;
                case ErrorKind.Internal : _failed = true; break;
                case ErrorKind.Notice   : break;
                case ErrorKind.Unhandled: _failed = true; break;
                case ErrorKind.Warning  : break;
                default:
                    throw new InternalError("Unknown ErrorKind value encountered: " + level.ToString());
            }

            // don't report the event if the trace level does not allow it
            if (level > _level)
                return;

            System.Text.StringBuilder result = new System.Text.StringBuilder();
            if (cursor != null)
                result.Append(cursor.ToString());
            if (result.Length > 0)
                result.Append(' ');

            string name = null;
            switch (level)
            {
                case ErrorKind.Debug    : name = "DEBUG";           break;
                case ErrorKind.Error    : name = "Error";           break;
                case ErrorKind.Fatal    : name = "Fatal error";     break;
                case ErrorKind.Internal : name = "Internal error";  break;
                case ErrorKind.Notice   : name = null;              break;
                case ErrorKind.Unhandled: name = "Unhandled error"; break;
                case ErrorKind.Warning  : name = "Warning";         break;
                default:
                    throw new InternalError("Unknown ErrorKind value encountered: " + level.ToString());
            }
            if (name != null)
                result.Append(name);
            if (code != 0)
                result.Append(" " + code.ToString());
            if (name != null)
                result.Append(": ");

            result.Append(text);

            _writer.WriteLine(result.ToString());
        }
Exemplo n.º 4
0
 public void PrintError(Cursor cursor, ErrorKind kind, int code, string text)
 {
     throw new ScannerError(cursor, string.Format("{0} {1}: {2}", kind.ToString(), code, text));
 }