• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2008, SnakeYAML
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package org.yaml.snakeyaml.reader;
15 
16 import org.yaml.snakeyaml.error.YAMLException;
17 
18 public class ReaderException extends YAMLException {
19 
20   private static final long serialVersionUID = 8710781187529689083L;
21   private final String name;
22   private final int codePoint;
23   private final int position;
24 
ReaderException(String name, int position, int codePoint, String message)25   public ReaderException(String name, int position, int codePoint, String message) {
26     super(message);
27     this.name = name;
28     this.codePoint = codePoint;
29     this.position = position;
30   }
31 
getName()32   public String getName() {
33     return name;
34   }
35 
getCodePoint()36   public int getCodePoint() {
37     return codePoint;
38   }
39 
getPosition()40   public int getPosition() {
41     return position;
42   }
43 
44   @Override
toString()45   public String toString() {
46     final String s = new String(Character.toChars(codePoint));
47     return "unacceptable code point '" + s + "' (0x" + Integer.toHexString(codePoint).toUpperCase()
48         + ") " + getMessage() + "\nin \"" + name + "\", position " + position;
49   }
50 }
51