Skip to content

Conversation

chriddyp
Copy link
Member

Our error messages are printed in the terminal & in the dash dev tools console. In both cases, we treat white space literally in order to display nice tracebacks. However, some of our error messages are indented. This PR dedents these error messages.

Example of behavior:

image

optionals

  • I have added entry in the CHANGELOG.md

Co-authored-by: Ryan Patrick Kyle <[email protected]>
@alexcjohnson
Copy link
Collaborator

I'm puzzled as to why this is necessary - we tried to dedent all the Dash exceptions in the base class.

class DashException(Exception):
def __init__(self, msg=""):
super(DashException, self).__init__(dedent(msg).strip())

If you manage to figure out the test failures, they seem to be the same as @almarklein sees in plotly/dash-core-components#905 - something broke in the dash-html-components build process? If nothing else I'll try and sort this out later this afternoon.

@alexcjohnson
Copy link
Collaborator

alexcjohnson commented Dec 15, 2020

In the specific example you show above, dedent is not going to fix the problem because it will only remove a consistent number of spaces from each line, and the lines [0] Tab and [2] function have no indentation. This comes from when path is inserted in the string here:

dash/dash/_validate.py

Lines 180 to 184 in cd2ff7c

The value in question is located at
{} {} {}
{},
""".format(
index_string, outer_type, outer_id, path

because path is a result of '\n'.join(...) in various places, meaning it has unindented lines within it.

Seems to me the solution is to indent subsequent lines of path, something like path.replace('\n', ' ' * 12 + '\n'), and use that pattern anywhere else we have multiline args interpolated in these messages.

@alexcjohnson
Copy link
Collaborator

superseded by #1530

@alexcjohnson alexcjohnson deleted the dedent-error-messages-3 branch January 17, 2021 01:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants