Skip to content

Commit 7934de8

Browse files
Update documentation and prepare release (#29)
Fixes #16, #22 --------- Co-authored-by: Christoph Pirkl <christoph.pirkl@exasol.com>
1 parent f10b253 commit 7934de8

12 files changed

Lines changed: 110 additions & 164 deletions

File tree

README.md

Lines changed: 55 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,74 @@
1-
# Error Reporting Python
1+
# Exasol Error Reporting
22

3-
This project contains a python library for describing Exasol error messages.
3+
This project contains a Python library for describing Exasol error messages.
44
This library lets you define errors with a uniform set of attributes.
55
Furthermore, the error message is implemented to be parseable,
66
so that you can extract an error catalog from the code.
77

88
## In a Nutshell
99

10-
Create an error object:
10+
### Install the library
1111

12-
```python
13-
exa_error_obj = ExaError.message_builder('E-TEST-1')
14-
.message("Not enough space on device {{device}}.")
15-
.mitigation("Delete something from {{device}}.")
16-
.mitigation("Create larger partition.")
17-
.parameter("device", "/dev/sda1", "name of the device")
12+
```shell
13+
pip install exasol-error-reporting
1814
```
1915

20-
Use it as string:
16+
### Create a Simple Error
17+
18+
```python
19+
from exasol import error
20+
21+
error1 = error.ExaError(
22+
"E-TEST-1", "A trivial error", "No mitigation available", {}
23+
)
24+
```
2125

26+
### Specify Multiple Mitigations
2227
```python
23-
print(exa_error_obj)
28+
from exasol import error
29+
30+
error2 = error.ExaError(
31+
"E-TEST-2",
32+
"Fire in the server room",
33+
[
34+
"Use the fire extinguisher",
35+
"Flood the room with halon gas (Attention: be sure no humans in the room!)"
36+
],
37+
{}
38+
)
2439
```
2540

26-
Result:
41+
### Error Parameter(s) without description
2742

43+
```python
44+
from exasol import error
45+
46+
error3 = error.ExaError(
47+
"E-TEST-2",
48+
"Not enough space on device {{device}}.",
49+
"Delete something from {{device}}.",
50+
{"device": "/dev/sda1"},
51+
)
2852
```
29-
E-TEST-1: Not enough space on device '/dev/sda1'. Known mitigations:
30-
* Delete something from '/dev/sda1'.
31-
* Create larger partition.
53+
### Error with detailed Parameter(s)
54+
55+
```python
56+
from exasol import error
57+
from exasol.error import Parameter
58+
59+
error4 = error.ExaError(
60+
"E-TEST-2",
61+
"Not enough space on device {{device}}.",
62+
"Delete something from {{device}}.",
63+
{"device": Parameter("/dev/sda1", "name of the device")},
64+
)
3265
```
3366

3467
Check out the [user guide](doc/user_guide/user_guide.md) for more details.
3568

3669
## Tooling
3770

38-
The `error-reporting-python` library comes with a command line tool (`ec`) which also can be invoked
71+
The `exasol-error-reporting` library comes with a command line tool (`ec`) which also can be invoked
3972
by using its package/module entry point (`python -m exasol.error`).
4073
For detailed information about the usage consider consulting the help `ec --help` or `python -m exasol.error --help`.
4174

@@ -58,6 +91,12 @@ you can use the generate subcommand.
5891
ec generate NAME VERSION PACKAGE_ROOT > error-codes.json
5992
```
6093

94+
## Known Issues
95+
96+
* [Throws exception on invalid error code format](https://github.com/exasol/error-reporting-python/issues/27)
97+
* [Single mitigations only can be passed within a list](https://github.com/exasol/error-reporting-python/issues/26)
98+
* [Named parameters do not work for error construction](https://github.com/exasol/error-reporting-python/issues/25)
99+
61100
### Information for Users
62101

63102
* [User Guide](doc/user_guide/user_guide.md)

doc/changes/changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Changelog
22

3+
* [unreleased](unreleased.md)
4+
* [0.4.0](changes_0.4.0.md)
35
* [0.3.0](changes_0.3.0.md)
46
* [0.2.0](changes_0.2.0.md)
57
* [0.1.0](changes_0.1.0.md)

doc/changes/changes_0.4.0.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
# error-reporting-python 0.4.0, released T.B.D
1+
# exasol-error-reporting 0.4.0, released 2023-09-27
22

3-
Code Name: T.B.D
3+
Code Name: API Rework and package renaming
44

55
## Summary
66

7-
T.B.D
7+
Reworked the API to be more pythonic and easier to parse. Also the package has
8+
been renamed in order to fit the pypi naming scheme.
89

9-
## Feature
10+
### Feature
1011
- #4: Add error parser/crawler cli tool
1112

1213
### Refactoring
1314

15+
- Renamed python package from `exasol-error-reporting-python` to `exasol-error-reporting`.
1416
- #19: Rework error reporting API
15-
- #17: Removed setup.py and updated poetry in actions
17+
- #17: Removed setup.py and updated poetry in actions
18+
19+
### Documentation
20+
21+
- #22: Update documentation
22+
- #16: Add note on pypi to README
23+

doc/changes/unreleased.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# exasol-error-reporting X.Y.Z, released YYYY-MM-DD
2+
3+
Code Name:
4+
5+
## Summary
6+
7+
### Security
8+
### Bugfix
9+
### Feature
10+
### Refactoring
11+
### Documentation

doc/dependencies.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99

1010
## Test Dependencies
1111

12-
| Dependency | Purpose | License |
13-
|-------------------------------|-----------------------------------|-------------------|
14-
| [Pytest][pytest] | Testing framework | MIT |
12+
| Dependency | Purpose | License |
13+
|------------------|-----------------------------------|---------|
14+
| [Pytest][pytest] | Testing framework | MIT |
15+
| [Prysk][prysk] | Testing framework | GPL |
1516

1617

1718

1819
[python]: https://docs.python.org
19-
2020
[pytest]: https://docs.pytest.org/en/stable/
21+
[prysk]: https://www.prysk.net

doc/design.md

Whitespace-only changes.

doc/developer_guide/building_documentation.md

Whitespace-only changes.

doc/developer_guide/developer_guide.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

doc/system_requirements.md

Whitespace-only changes.

doc/user_guide/user_guide.md

Lines changed: 14 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,16 @@ This library lets you define errors with a uniform set of attributes.
55
Furthermore, the error message is implemented to be parseable,
66
so that you can extract an error catalog from the code.
77

8-
## Attributes of Error Builder
8+
## Creating an Error Object
99

10-
Error messages are built in `ExaError` using the following predefined attributes.
11-
All attributes of the error object except the error code are optional. Thus, the
12-
`ExaError` will still work, even if the other attributes are not provided. Please
13-
keep in mind that error-code should satisfy error-code format
14-
(see [error-code](#error-code)).
10+
Error objects are built using the function `ExaError`.
11+
Please keep in mind that error-code should satisfy the error-code format (see [code](#code)).
1512

1613
Flexibility is provided by introducing placeholder parameters to the error
17-
message in two ways: (1) via the `parameter` attribute and (2) with positional
18-
arguments. Furthermore, placeholders without parameters are filled with <null>.
14+
message.
1915

20-
#### error-code
21-
This attribute should be defined in the error message and provide the following
22-
pattern (`^[FEW]-[[A-Z][A-Z0-9]+(-[A-Z][A-Z0-9]+)*-[0-9]+$`):
16+
#### code
17+
This parameter needs to obey the following format (`^[FEW]-[[A-Z][A-Z0-9]+(-[A-Z][A-Z0-9]+)*-[0-9]+$`):
2318

2419
`severity "-" project-short-tag ["-" module-short-tag] "-" error-number` where,
2520
- _severity_: either F (Failure, not recoverable), or E (Error, recoverable),
@@ -34,120 +29,14 @@ Examples of valide error codes:
3429
- F-VS-QRW-13
3530

3631
#### message
37-
This attribute includes error description which can be given by either a static
32+
This parameter includes the error description which can be given by either a static
3833
string or a string containing placeholders in double curly brackets. Parameters
39-
of placeholders in the error message can be given as positional arguments
40-
as well as using the `parameter` attribute. The following two usages result in
41-
the same message (`Error message with value`):
42-
- `.message("Error message with {{parameter}}", "value")`
43-
- `.message("Error message with {{parameter}}").parameter("parameter", "value")`
34+
of placeholders in the error message can be provided using the `parameters` parameter.
4435

45-
Furthermore, multiple calls of the `message` method will append the corresponding
46-
message to the previous ones.
47-
48-
#### mitigation
49-
This attribute provides a list of hints on how to fix the error. Its method
50-
structure is the same as for the `message` attribute. Parameters of placeholders
51-
in the mitigations can be given as positional arguments as well as using the
52-
`parameter` attribute. Similar to the `message` method, multiple calls of
53-
the `mitigation` method will append the corresponding mitigation to the
54-
previous ones.
36+
#### mitigations
37+
This parameter provides a list of hints on how to fix the error.
38+
Parameters of placeholders in the mitigations can be given via the `parameters` parameter.
5539

56-
Furthermore, if the only message we can give is to open a ticket, the
57-
`ticket mitigation()` method can be called, which provides a predefined message
58-
about it.
59-
60-
#### parameter
61-
This attribute takes the placeholder name and the parameter value
62-
that will replace this placeholder as argument. It can be used for both message
63-
and mitigations. For example usages, please see the
64-
[Parameters](#Parameters) section.
65-
66-
## Usage
67-
68-
### Simple Messages
69-
```python
70-
ExaError.message_builder("E-TEST-1").message("Something went wrong.")
71-
```
72-
The result of the error message:
73-
```
74-
E-TEST-1: Something went wrong.
75-
```
76-
77-
78-
### Parameters
79-
You can specify placeholders in the message and replace them with
80-
parameters values.
81-
82-
```python
83-
ExaError.message_builder("E-TEST-2")
84-
.message("Unknown input: {{input}}.")
85-
.parameter("input", "unknown", "The illegal user input.")
86-
```
87-
or inline:
88-
```python
89-
ExaError.message_builder("E-TEST-2")
90-
.message("Unknown input: {{input}}.", "unknown")
91-
```
92-
The result of both error messages is same:
93-
```
94-
E-TEST-2: Unknown input: 'unknown'.
95-
```
96-
97-
The optional third argument for `parameter(name, value, description)`
98-
method is used to generate a parameter description for the error-catalog.
99-
100-
The builder automatically quotes parameters (depending on the type of the
101-
parameter). If you don't want that, use the `|uq` suffix in the corresponding
102-
placeholder, as follows:
103-
104-
```python
105-
ExaError.message_builder("E-TEST-2")
106-
.message("Unknown input: {{input|uq}}.")
107-
.parameter("input", "unknown", "The illegal user input.")
108-
```
109-
The result of the error message:
110-
```
111-
E-TEST-2: Unknown input: unknown.
112-
```
113-
114-
### Mitigations
115-
The mitigations describe actions the user can take to resolve the error.
116-
Here is an example of a mitigation definition:
117-
118-
```python
119-
ExaError.message_builder("E-TEST-2")
120-
.message("Not enough space on device.")
121-
.mitigation("Delete something.")
122-
```
123-
The result of the error message:
124-
```
125-
E-TEST-2: Not enough space on device. Delete something.
126-
```
127-
128-
You can use parameters in mitigations too.
129-
```python
130-
ExaError.message_builder("E-TEST-2")
131-
.message("Not enough space on device {{device}}.")
132-
.mitigation("Delete something from {{device}}.")
133-
.parameter("device", "/dev/sda1", "name of the device")
134-
```
135-
The result of the error message:
136-
```
137-
E-TEST-2: Not enough space on device '/dev/sda1'. Delete something from '/dev/sda1'.
138-
```
139-
140-
You can chain `mitigation` definitions if you want to tell the users that there
141-
is more than one solution, as follows:
142-
```python
143-
ExaError.message_builder("E-TEST-2")
144-
.message("Not enough space on device.")
145-
.mitigation("Delete something.")
146-
.mitigation("Create larger partition.")
147-
```
148-
The result of the error message:
149-
```
150-
E-TEST-2: Not enough space on device. Known mitigations:
151-
* Delete something.
152-
* Create larger partition.
153-
```
40+
#### parameters
41+
This argument takes a dictionary of placeholder names and the respective parameter values.
42+
They will be used to replace the placeholders in the mitigations and messages.

0 commit comments

Comments
 (0)