Skip to content

Commit

Permalink
Expose the error details field. (#479)
Browse files Browse the repository at this point in the history
Error details get exposed as `_details` property.
  • Loading branch information
vpetrovykh authored and aljazerzen committed Feb 15, 2024
1 parent 60da99a commit 113ed0d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion edgedb/errors/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ def _hint(self):
# not a stable API method
return self._read_str_field(FIELD_HINT)

@property
def _details(self):
# not a stable API method
return self._read_str_field(FIELD_DETAILS)

def _read_str_field(self, key, default=None):
val = self._attrs.get(key)
if val:
Expand Down Expand Up @@ -156,6 +161,7 @@ def __str__(self):
self._line if self._line > 0 else "?",
self._col if self._col > 0 else "?",
self._hint or "error",
self._details,
)
except Exception:
return "".join(
Expand Down Expand Up @@ -226,7 +232,7 @@ def _severity_name(severity):
return 'PANIC'


def _format_error(msg, query, start, offset, line, col, hint):
def _format_error(msg, query, start, offset, line, col, hint, details):
c = get_color()
rv = io.StringIO()
rv.write(f"{c.BOLD}{msg}{c.ENDC}{LINESEP}")
Expand Down Expand Up @@ -278,6 +284,10 @@ def _format_error(msg, query, start, offset, line, col, hint):
rv.write(f"{c.BLUE}{'':>{num_len}} │ "
f"{c.FAIL}╰─{'─' * (size - 1)}^ {hint}{c.ENDC}")
break

if details:
rv.write(f"{LINESEP}Details: {details}")

return rv.getvalue()


Expand Down

0 comments on commit 113ed0d

Please sign in to comment.