Commit 1814f1c
committed
Tweak _ConverterError reporting.
Chaining an empty _ConverterError doesn't add useful info; instead,
print out the output stream.
e.g. modify _GSConverter to use the invalid `-sDEVICE=1234`; previously
`_GSConverter()("foo", "bar")` would give:
```
Traceback (most recent call last):
File ".../matplotlib/testing/compare.py", line 110, in __call__
self._read_until(b"\nGS")
File ".../matplotlib/testing/compare.py", line 95, in _read_until
raise _ConverterError
matplotlib.testing.compare._ConverterError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/antony/src/extern/matplotlib/lib/matplotlib/testing/compare.py", line 112, in __call__
raise OSError("Failed to start Ghostscript") from err
OSError: Failed to start Ghostscript
```
or, if just passing buf as parameter when constructing the
_ConverterError:
```
Traceback (most recent call last):
File ".../matplotlib/testing/compare.py", line 110, in __call__
self._read_until(b"\nGS")
File ".../matplotlib/testing/compare.py", line 95, in _read_until
raise _ConverterError(buf)
matplotlib.testing.compare._ConverterError: bytearray(b'GPL Ghostscript 9.55.0 (2021-09-27)\nCopyright (C) 2021 Artifex Software, Inc. All rights reserved.\nThis software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:\nsee the file COPYING for details.\nUnknown device: 1234\n')
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../matplotlib/testing/compare.py", line 112, in __call__
raise OSError("Failed to start Ghostscript") from err
OSError: Failed to start Ghostscript
```
and now it gives:
```
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../matplotlib/testing/compare.py", line 112, in __call__
raise OSError("Failed to start Ghostscript:\n\n" + err.args[0]) from None
OSError: Failed to start Ghostscript:
GPL Ghostscript 9.55.0 (2021-09-27)
Copyright (C) 2021 Artifex Software, Inc. All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
Unknown device: 1234
```1 parent c9614de commit 1814f1c
1 file changed
+6
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
95 | | - | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
| 112 | + | |
| 113 | + | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| |||
172 | 173 | | |
173 | 174 | | |
174 | 175 | | |
175 | | - | |
176 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
| |||
0 commit comments