w3c.css.error.ErrorReportHTML Maven / Gradle / Ivy
Show all versions of cssvalidator Show documentation
// $Id$
// Author: Jean-Guilhem Rouel
// (c) COPYRIGHT MIT, ERCIM and Keio, 2003.
// Please first read the full copyright statement in file COPYRIGHT.html
package org.w3c.css.error;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.w3c.css.util.ApplContext;
import org.w3c.css.util.Util;
import org.xml.sax.SAXParseException;
import java.io.DataInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URL;
/**
* ErrorReportHTML
* Created: Jul 13, 2005 2:05:51 PM
* This class is used to create an (x)html page when a URI error is thrown by
* the servlet
*/
public class ErrorReportHTML extends ErrorReport {
// ApplContext ac;
String title;
Exception e;
public ErrorReportHTML(ApplContext ac, String title, String output, Exception e) {
// ac is not used for now, but may be useful
// this.ac = ac;
this.title = title;
this.e = e;
}
/**
* @see org.w3c.css.error.ErrorReport#print(java.io.PrintWriter)
*/
public void print(PrintWriter out) {
try {
URL localURL = ErrorReportHTML.class.getResource("error.html");
DataInputStream in = new DataInputStream(localURL.openStream());
try {
while (true) {
out.print((char) in.readUnsignedByte());
}
} catch (EOFException eof) {
out.println("Target: " + Util.escapeHTML(title) + "
");
out.println("");
if (e instanceof ResourceNotFoundException) {
out.println("" + e.toString() + "
");
} else if (e instanceof IOException) {
out.println("I/O Error: ");
out.println(Util.escapeHTML(e.getMessage()));
} else if (e instanceof SAXParseException) {
SAXParseException saxe = (SAXParseException) e;
out.println("
Please, validate your XML document" + " first!
");
if (saxe.getLineNumber() != -1) {
out.print("Line ");
out.print(saxe.getLineNumber());
out.println("
");
}
if (saxe.getColumnNumber() != -1) {
out.print("Column ");
out.print(saxe.getColumnNumber());
out.print("
\n");
}
out.println("" + Util.escapeHTML(e.getMessage()));
} else if (e instanceof NullPointerException) {
out.println("
Oups! Internal error!
");
e.printStackTrace();
} else {
out.println(e.toString());
}
out.println("
\n
\n\nwww-validator-css\n