1 /**
2 * Copyright 2006-2016 the original author or authors.
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 package org.mybatis.generator.exception;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 /**
22 * The Class XMLParserException.
23 *
24 * @author Jeff Butler
25 */
26 public class XMLParserException extends Exception {
27
28 /** The Constant serialVersionUID. */
29 private static final long serialVersionUID = 5172525430401340573L;
30
31 /** The errors. */
32 private List<String> errors;
33
34 /**
35 * Instantiates a new XML parser exception.
36 *
37 * @param errors
38 * the errors
39 */
40 public XMLParserException(List<String> errors) {
41 super();
42 this.errors = errors;
43 }
44
45 /**
46 * Instantiates a new XML parser exception.
47 *
48 * @param error
49 * the error
50 */
51 public XMLParserException(String error) {
52 super(error);
53 this.errors = new ArrayList<String>();
54 errors.add(error);
55 }
56
57 /**
58 * Gets the errors.
59 *
60 * @return the errors
61 */
62 public List<String> getErrors() {
63 return errors;
64 }
65
66 /* (non-Javadoc)
67 * @see java.lang.Throwable#getMessage()
68 */
69 @Override
70 public String getMessage() {
71 if (errors != null && errors.size() > 0) {
72 return errors.get(0);
73 }
74
75 return super.getMessage();
76 }
77 }