1
2
3
4
5
6
7
8
9
10
11 package org.csveed.report;
12
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16
17
18
19 public class CsvException extends RuntimeException {
20
21
22 private static final long serialVersionUID = 1L;
23
24
25 private static final Logger LOG = LoggerFactory.getLogger(CsvException.class);
26
27
28 private CsvError error;
29
30
31
32
33
34
35
36 public CsvException(CsvError error) {
37 this.error = error;
38 for (String line : error.getPrintableLines()) {
39 LOG.error("{}", line);
40 }
41 }
42
43
44
45
46
47
48 public CsvError getError() {
49 return this.error;
50 }
51
52 @Override
53 public String getMessage() {
54 return this.getError().getMessage();
55 }
56
57 @Override
58 public String getLocalizedMessage() {
59 StringBuilder errorMessage = new StringBuilder();
60 boolean first = true;
61 for (String line : getError().getPrintableLines()) {
62 if (!first) {
63 errorMessage.append(System.lineSeparator());
64 }
65 errorMessage.append(line);
66 first = false;
67 }
68 return errorMessage.toString();
69 }
70
71 }