• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.google.streamhtmlparser;
18 
19 /**
20  * Checked exception thrown on an unrecoverable error during parsing.
21  *
22  * @see Parser#parse(String)
23  */
24 public class ParseException extends Exception {
25 
26   /**
27    * Constructs an {@code ParseException} with no detail message.
28    */
ParseException()29   public ParseException() {}
30 
31   /**
32    * Constructs an {@code ParseException} with a detail message obtained
33    * from the supplied message and the parser's line and column numbers.
34    * @param parser the {@code Parser} that triggered the exception
35    * @param msg the error message
36    */
ParseException(Parser parser, String msg)37   public ParseException(Parser parser, String msg) {
38     super(String.format("At line: %d (col: %d); %s",
39                         parser.getLineNumber(),
40                         parser.getColumnNumber(),
41                         msg));
42   }
43 }
44