diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/throwables')
3 files changed, 72 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/throwables/IllegalNameException.java b/src/main/java/cuchaz/enigma/throwables/IllegalNameException.java new file mode 100644 index 0000000..fa21a9e --- /dev/null +++ b/src/main/java/cuchaz/enigma/throwables/IllegalNameException.java | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.throwables; | ||
| 12 | |||
| 13 | public class IllegalNameException extends RuntimeException { | ||
| 14 | |||
| 15 | private String name; | ||
| 16 | private String reason; | ||
| 17 | |||
| 18 | public IllegalNameException(String name, String reason) { | ||
| 19 | this.name = name; | ||
| 20 | this.reason = reason; | ||
| 21 | } | ||
| 22 | |||
| 23 | public String getReason() { | ||
| 24 | return this.reason; | ||
| 25 | } | ||
| 26 | |||
| 27 | @Override | ||
| 28 | public String getMessage() { | ||
| 29 | StringBuilder buf = new StringBuilder(); | ||
| 30 | buf.append("Illegal name: "); | ||
| 31 | buf.append(this.name); | ||
| 32 | if (this.reason != null) { | ||
| 33 | buf.append(" because "); | ||
| 34 | buf.append(this.reason); | ||
| 35 | } | ||
| 36 | return buf.toString(); | ||
| 37 | } | ||
| 38 | } | ||
diff --git a/src/main/java/cuchaz/enigma/throwables/MappingConflict.java b/src/main/java/cuchaz/enigma/throwables/MappingConflict.java new file mode 100644 index 0000000..5924f32 --- /dev/null +++ b/src/main/java/cuchaz/enigma/throwables/MappingConflict.java | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | package cuchaz.enigma.throwables; | ||
| 2 | |||
| 3 | public class MappingConflict extends Exception { | ||
| 4 | public MappingConflict(String clazz, String name, String nameExisting) { | ||
| 5 | super(String.format("Conflicting mappings found for %s. The mapping file is %s and the second is %s", clazz, name, nameExisting)); | ||
| 6 | } | ||
| 7 | } | ||
diff --git a/src/main/java/cuchaz/enigma/throwables/MappingParseException.java b/src/main/java/cuchaz/enigma/throwables/MappingParseException.java new file mode 100644 index 0000000..93ae2fd --- /dev/null +++ b/src/main/java/cuchaz/enigma/throwables/MappingParseException.java | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.throwables; | ||
| 12 | |||
| 13 | public class MappingParseException extends Exception { | ||
| 14 | |||
| 15 | private int m_line; | ||
| 16 | private String m_message; | ||
| 17 | |||
| 18 | public MappingParseException(int line, String message) { | ||
| 19 | m_line = line; | ||
| 20 | m_message = message; | ||
| 21 | } | ||
| 22 | |||
| 23 | @Override | ||
| 24 | public String getMessage() { | ||
| 25 | return "Line " + m_line + ": " + m_message; | ||
| 26 | } | ||
| 27 | } | ||