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 29, 2024
1 parent d97d0ed commit 6da3a65
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions pgtoolkit/errors.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
from __future__ import annotations

from dataclasses import 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 "<%s at line %d: %.32s>" % (
self.__class__.__name__,
self.lineno,
self.message,
)
@dataclass
class ParseError(Exception):
lineno: int
line: str
message: str

def __str__(self) -> str:
return "Bad line #{} '{:.32}': {}".format(
Expand Down

0 comments on commit 6da3a65

Please sign in to comment.