1
Vote

Error Loading file

description

Yalv>File>Open... fails with the attached log file since it contains lines where the 'Line' information is not stated (see screenshot, sample file, and stacktrace in attachment).

We need to improve the error handling to make finding these problems more obvious. One change is, for example, to add a corresponding error message as indicated below. The error message shows the line and position of the offending data (this should make debugging issues a piece of cake).

I think we should think consciously about each error situation and the information that is required to give users a chance for resolving a specific problem. To do this, I've added the line number and position of the XML file below but I guess we should also add the file name itself.
        while (xr.Read())
        {
          if (xr.NodeType == XmlNodeType.Element && xr.LocalName == "event")
          {
            log4jEvent = Deserialize(xr);
            try
            {
              entry = Event2LogEntry.Convert(log4jEvent);
            }
            catch (Exception ex)
            {
              IXmlLineInfo xmlInfo = (IXmlLineInfo)xr;

              throw new Exception(string.Format("Problem parsing line number: {0}, position {1}",
                                                xmlInfo.LineNumber, xmlInfo.LinePosition), ex);
            }

            entries.Add(entry);

            // [FT] We may need that in the future.
            //        if (filterByParameters(entry, filter))
            //        {
            //          yield return entry;
            //          entryId++;
            //        }
          }
        }
The above code should be supported by specific exceptions being passed on in critical parts (in this example in Event2LogEntry.cs). The actual solution for this specific case is probably to expect data not to be available and set an obvious default instead (e.g. -1) but what I am trying to get at is that we need to implement exceptions (in the subsystem) that contain enough information to debug the problem.

These exceptions should be passed on to the client application (Yalv, YalvLib) where they can be displayed using, for example, a view like this:

https://edi.codeplex.com/wikipage?title=Themed%20message%20boxes&referringTitle=list%20of%20features

(see last two screenshots)
            try
            {
              _logEntry.Line = System.Convert.ToUInt32(_log4jEvent.LocationInfo.Line);
            }
            catch (Exception ex)
            {
              throw new Exception("Converting line number field in log4j file failed.", ex);
            }

file attachments

comments