Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the error details field. #479

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading