Coverage for src/hatch_ci/exceptions.py: 96%

# Coverage for src/hatch_ci/exceptions.py : 96%

## 27 statements 26 run 1 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | from __future__ import annotations from . import text class AbortExecutionError(Exception): @staticmethod def _strip(txt): txt = txt or "" txt = txt[1:] if txt.startswith("\n") else txt txt = text.indent(txt, pre="") return txt[:-1] if txt.endswith("\n") else txt def __init__( self, message: str, explain: str | None = None, hint: str | None = None ): self.message = message.strip() self._explain = explain self._hint = hint @property def explain(self): return self._strip(self._explain) @property def hint(self): return self._strip(self._hint) def __str__(self): result = [self.message] if self.explain: result.append(text.indent("\n" + self.explain, pre=" " * 2)[2:]) if self.hint: result.extend(["\nhint:", text.indent("\n" + self.hint, pre=" " * 2)[2:]]) return "".join(result)