1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.toolchain.building;
20
21 import java.io.PrintWriter;
22 import java.io.StringWriter;
23 import java.util.ArrayList;
24 import java.util.List;
25
26 import org.apache.maven.building.Problem;
27
28
29
30
31
32 @Deprecated(since = "4.0.0")
33 public class ToolchainsBuildingException extends Exception {
34
35 private final List<Problem> problems;
36
37
38
39
40
41
42 public ToolchainsBuildingException(List<Problem> problems) {
43 super(toMessage(problems));
44
45 this.problems = new ArrayList<>();
46 if (problems != null) {
47 this.problems.addAll(problems);
48 }
49 }
50
51
52
53
54
55
56 public List<Problem> getProblems() {
57 return problems;
58 }
59
60 private static String toMessage(List<Problem> problems) {
61 StringWriter buffer = new StringWriter(1024);
62
63 PrintWriter writer = new PrintWriter(buffer);
64
65 writer.print(problems.size());
66 writer.print((problems.size() == 1) ? " problem was " : " problems were ");
67 writer.print("encountered while building the effective toolchains");
68 writer.println();
69
70 for (Problem problem : problems) {
71 writer.print("[");
72 writer.print(problem.getSeverity());
73 writer.print("] ");
74 writer.print(problem.getMessage());
75 String location = problem.getLocation();
76 if (!location.isEmpty()) {
77 writer.print(" @ ");
78 writer.print(location);
79 }
80 writer.println();
81 }
82
83 return buffer.toString();
84 }
85 }