You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-16Lines changed: 37 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,37 +44,58 @@ Result:
44
44
45
45
The optional third parameter for `parameter(placeholder, value, description)` is used by the [error-code-crawler-maven-plugin](https://github.com/exasol/error-code-crawler-maven-plugin) to generate a parameter description.
46
46
47
-
The builder automatically quotes parameters of the following types:
48
-
49
-
*`String`
50
-
*`Character`
51
-
*`Path`
52
-
*`File`
53
-
*`URI`
54
-
*`URL`
55
-
56
-
If you don't want that, use the `uq` switch in the correspondent placeholder. Switches are separated with a pipe symbol "|" from the parameter name.
47
+
From version `0.3.0` on you can achieve the same result by specifying the parameter values directly in the `message()` method. This is a convenience variant that is a little more compact, but lacks the chance to describe the parameter.
57
48
58
49
```java
59
50
ExaError.messageBuilder("E-TEST-2")
60
-
.message("Unknown input: {{input|uq}}.")
61
-
.parameter("input", "unknown", "The illegal user input.").toString();
51
+
.message("Message with {{first-parameter}} and {{second-parameter}}.", "first value", "second value").toString();
62
52
```
63
53
64
54
Result:
65
55
66
-
E-TEST-2: Unknown input: unknown.
56
+
E-TEST-2: Message with 'q-value' and uq-value.
57
+
58
+
#### Automatic Quoting
59
+
60
+
When replacing placeholders in messages, `ExaError` quotes the values according to your choices. If you don't specify a quoting option in a placeholder, you get auto-quoting. In this mode values are quoted depending on their type.
|`URI`| single quotes |`'URN:ISBN:0-330-28700-1'`| 1.0.0 |
69
+
|`URL`| single quotes |`'https://example.org'`| 1.0.0 |
70
+
| null values | pointy brackets |`<null>`||
71
+
| everything else | not quoted |`42`, `3.1415`, `true`||
72
+
73
+
#### Manual Quoting
67
74
68
-
From version `0.3.0` on you can achieve the same result by specifying the parameter values directly in the `message()` method. This is a convenience variant that is a little bit more compact, but lacks the chance to describe the parameter.
75
+
If you need a different quoting style, you can add switches to the placeholder definition:
76
+
77
+
`u`
78
+
: unquoted
79
+
80
+
`q`
81
+
: forced single quotes
82
+
83
+
`d`
84
+
: forced double quotes
85
+
86
+
If multiple conflicting switches are given, the one with the highest precedence (see list above) is taken.
87
+
88
+
Switches are separated with a pipe symbol `|` from the parameter name.
69
89
70
90
```java
71
91
ExaError.messageBuilder("E-TEST-2")
72
-
.message("Message with {{quotedParameter}} and {{unquotedParameter|uq}}.", "q-value", "uq-value").toString();
92
+
.message("Unknown input: {{input|u}}.")
93
+
.parameter("input", "unknown", "The illegal user input.").toString();
Copy file name to clipboardExpand all lines: doc/changes/changes_1.0.0.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,33 @@
1
-
# error-reporting-java 1.0.0, released 2022-08-30
1
+
# error-reporting-java 1.0.0, released 2022-09-02
2
2
3
3
Code name: Quoting enhancements
4
4
5
5
In this release we added a guideline for deleting error codes and migrated the project to Project Keeper 2.
6
6
7
7
When you use Java types `Path`, `File`, `URL` or `URI` as parameter in a message, it now automatically gets quoted. Note that this can break existing unit tests in you code or client code that parses error messages.
8
8
9
+
We also now support quoting with double quotes.
10
+
9
11
Note that we removed the deprecated `unquotedParameter` methods.
10
12
11
-
For the reviewers: open TODOs for this release: #28, #27, #19
13
+
Quoting is now exclusively controlled by the following single-character switches:
14
+
15
+
`u`
16
+
: unquoted
17
+
18
+
`q`
19
+
: forced single quotes
20
+
21
+
`d`
22
+
: forced double quotes
23
+
24
+
none
25
+
: automatic quoting depending on the type
26
+
27
+
If multiple conflicting switches are given, the one with the highest precedence (see list above) is taken.
28
+
That means the previous `uq` switch still works because the `q` is ignored in this case.
29
+
30
+
Quoting now supports all collections, not only lists.
0 commit comments