Skip to content

Commit

Permalink
Define ParseError as a dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
pgiraud committed Nov 28, 2024
1 parent 13496b8 commit 946b137
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pgtoolkit/errors.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
from __future__ import annotations

from dataclasses import dataclass


@dataclass
class ParseError(Exception):
def __init__(self, lineno: int, line: str, message: str) -> None:
self.message = message
super().__init__(self.message)
self.lineno = lineno
self.line = line

def __repr__(self) -> str:
return f"<{self.__class__.__name__} at line {self.lineno}: {self.message:.32}>"
lineno: int
line: str
message: str

def __str__(self) -> str:
return f"Bad line #{self.lineno} '{self.line.strip():.32}': {self.message}"

0 comments on commit 946b137

Please sign in to comment.