- From: CVS User ylafon <cvsmail@w3.org>
- Date: Tue, 09 Apr 2013 14:55:05 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2002/css-validator/org/w3c/css/parser In directory roscoe:/tmp/cvs-serv24782/org/w3c/css/parser Modified Files: CssError.java Log Message: make the error type (used as they key to generate the message) accessible in the CssError class --- /sources/public/2002/css-validator/org/w3c/css/parser/CssError.java 2009/02/25 20:44:49 1.6 +++ /sources/public/2002/css-validator/org/w3c/css/parser/CssError.java 2013/04/09 14:55:05 1.7 @@ -1,5 +1,5 @@ // -// $Id: CssError.java,v 1.6 2009/02/25 20:44:49 ylafon Exp $ +// $Id: CssError.java,v 1.7 2013/04/09 14:55:05 ylafon Exp $ // From Philippe Le Hegaret (Philippe.Le_Hegaret@sophia.inria.fr) // // (c) COPYRIGHT MIT and INRIA, 1997. @@ -7,84 +7,109 @@ package org.w3c.css.parser; +import org.w3c.css.util.InvalidParamException; import org.w3c.css.util.Messages; /** * This class represents an unknown error during the parse. * - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public class CssError { - /** - * The source file - */ - String sourceFile; - - /** - * The line number in the file - */ - int line; - - /** - * The unknown error - */ - Throwable error; - - /** - * Create a new CssError - */ - public CssError() { - } - - /** - * Create a new CssError - * - * @param sourceFile The source file - * @param line The error line number - * @param error The exception - */ - public CssError(String sourceFile, int line, Throwable error) { - this.sourceFile = sourceFile; - this.line = line; - this.error = error; - } - - /** - * Create a new CssError - * - * @param error The exception - */ - public CssError(Throwable error) { - this.error = error; - } - - /** - * Get the source file - */ - public String getSourceFile() { - return sourceFile; - } - - /** - * Get the source file - */ - public String getSourceFileEscaped() { - return Messages.escapeString(sourceFile); - } - - - /** - * get the line number - */ - public int getLine() { - return line; - } - - /** - * get the unknown error - */ - public Throwable getException() { - return error; - } + /** + * The source file + */ + String sourceFile; + + /** + * The line number in the file + */ + int line; + + /** + * The error type, taken from + * the error, if defined. + */ + String type = null; + /** + * The unknown error + */ + Throwable error; + + /** + * Create a new CssError + */ + public CssError() { + } + + /** + * Create a new CssError + * + * @param sourceFile The source file + * @param line The error line number + * @param error The exception + */ + public CssError(String sourceFile, int line, Throwable error) { + this.sourceFile = sourceFile; + this.line = line; + this.error = error; + } + + /** + * Create a new CssError + * + * @param error The exception + */ + public CssError(Throwable error) { + this.error = error; + } + + /** + * Get the source file + */ + public String getSourceFile() { + return sourceFile; + } + + /** + * Get the source file + */ + public String getSourceFileEscaped() { + return Messages.escapeString(sourceFile); + } + + + /** + * get the line number + */ + public int getLine() { + return line; + } + + /** + * get the unknown error + */ + public Throwable getException() { + return error; + } + + /** + * get the error type, null if undefined + */ + public String getType() { + if(type == null) { + if (error == null) { + return null; + } + if (error instanceof InvalidParamException) { + InvalidParamException exception = (InvalidParamException) error; + type = exception.getErrorType(); + } else { + type = error.getClass().getName(); + } + } + return type; + } } +
Received on Tuesday, 9 April 2013 14:55:07 UTC