Beispiel #1
0
 /// <summary> Print an error message.
 /// </summary>
 /// <param name="message">The message to print.
 /// </param>
 /// <param name="exception">The exception for stack tracing.
 ///
 /// </param>
 public virtual void Error(string message, ParserException exception)
 {
     if (mode != QUIET)
     {
         System.Console.Out.WriteLine("ERROR: " + message);
         if (mode == DEBUG && (exception != null))
         {
             SupportClass.WriteStackTrace(exception, Console.Error);
         }
     }
 }
Beispiel #2
0
 private Node ReadElement()
 {
     try
     {
         return(reader.ReadElement());
     }
     catch (System.Exception e)
     {
         System.Text.StringBuilder msgBuffer = new System.Text.StringBuilder();
         msgBuffer.Append("Unexpected Exception occurred while reading ");
         msgBuffer.Append(resourceLocn);
         msgBuffer.Append(", in nextHTMLNode");
         reader.AppendLineDetails(msgBuffer);
         ParserException ex = new ParserException(msgBuffer.ToString(), e);
         feedback.Error(msgBuffer.ToString(), ex);
         throw ex;
     }
 }
 public virtual void Error(string message, ParserException e)
 {
 }
Beispiel #4
0
        public NodeIterator CreateNodeIterator(bool remove_scanner, NodeIterator ret)
        {
            Node    node;
            MetaTag meta;
            string  httpEquiv;
            string  charset;
            EndTag  end;

            if (null != url)
            {
                try
                {
                    if (null == scanners["-m"])
                    {
                        AddScanner(new MetaTagScanner("-m"));
                        remove_scanner = true;
                    }

                    /* Read up to </HEAD> looking for charset directive */
                    while (ret.MoveNext())
                    {
                        node = (Node)ret.Current;
                        if (node is MetaTag)
                        {
                            // check for charset on Content-Type
                            meta      = (MetaTag)node;
                            httpEquiv = meta["HTTP-EQUIV"];
                            if ("Content-Type".ToUpper().Equals(httpEquiv.ToUpper()))
                            {
                                charset = getCharset(meta["CONTENT"]);
                                if (!charset.ToUpper().Equals(character_set.ToUpper()))
                                {
                                    // oops, different character set, restart
                                    character_set = charset;
                                }
                                // once we see the Content-Type meta tag we're finished the pre-read
                                break;
                            }
                        }
                        else if (node is EndTag)
                        {
                            end = (EndTag)node;
                            if (end.TagName.ToUpper().Equals("HEAD".ToUpper()))
                            {
                                // or, once we see the </HEAD> tag we're finished the pre-read
                                break;
                            }
                        }
                    }
                    // Reset the reader
                    RecreateReader();
                    ret = new NodeIterator(reader, resourceLocn, feedback);
                }

/* TODO				catch (UnsupportedEncodingException uee)
 *                              {
 *                                      string msg = "elements() : The content of " + url.RequestUri.ToString() + " has an encoding which is not supported";
 *                                      ParserException ex = new ParserException(msg, uee);
 *                                      feedback.Error(msg, ex);
 *                                      throw ex;
 *                              }
 */
                catch (IOException ioe)
                {
                    string          msg = "elements() : Error in opening a connection to " + url.RequestUri.ToString();
                    ParserException ex  = new ParserException(msg, ioe);
                    feedback.Error(msg, ex);
                    throw ex;
                }
            }
 public static void error(string message, ParserException e)
 {
     callback.Error(message, e);
 }