View Javadoc
1   package org.csveed.report;
2   
3   import org.slf4j.Logger;
4   import org.slf4j.LoggerFactory;
5   
6   public class CsvException extends RuntimeException {
7   
8       private static final long serialVersionUID = 1L;
9   
10      private static final Logger LOG = LoggerFactory.getLogger(CsvException.class);
11  
12      private CsvError error;
13  
14      public CsvException(CsvError error) {
15          this.error = error;
16          for (String line : error.getPrintableLines()) {
17              LOG.error("{}", line);
18          }
19      }
20  
21      public CsvError getError() {
22          return this.error;
23      }
24  
25      @Override
26      public String getMessage() {
27          return this.getError().getMessage();
28      }
29  
30      @Override
31      public String getLocalizedMessage() {
32          StringBuilder errorMessage = new StringBuilder();
33          boolean first = true;
34          for (String line : getError().getPrintableLines()) {
35              if (!first) {
36                  errorMessage.append(System.getProperty("line.separator"));
37              }
38              errorMessage.append(line);
39              first = false;
40          }
41          return errorMessage.toString();
42      }
43  
44  }