mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Merge pull request #3112 from Ad115/Ad115
Added emphasis to the error source
This commit is contained in:
commit
cc55c678c2
3 changed files with 25 additions and 2 deletions
23
news/prompt_error.rst
Normal file
23
news/prompt_error.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Changed:**
|
||||
|
||||
* Errors while formatting the prompt are highlighted for easier debugging.
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -94,7 +94,7 @@ def test_format_prompt_with_invalid_func(formatter, xonsh_builtins):
|
|||
def test_format_prompt_with_func_that_raises(formatter, capsys, xonsh_builtins):
|
||||
xonsh_builtins.__xonsh__.env = Env()
|
||||
template = "tt {zerodiv} tt"
|
||||
exp = "tt (ERROR:zerodiv) tt"
|
||||
exp = "tt {BACKGROUND_RED}{ERROR:zerodiv}{NO_COLOR} tt"
|
||||
fields = {"zerodiv": lambda: 1 / 0}
|
||||
obs = formatter(template, fields)
|
||||
assert exp == obs
|
||||
|
|
|
@ -83,7 +83,7 @@ class PromptFormatter:
|
|||
except Exception:
|
||||
print("prompt: error: on field {!r}" "".format(field), file=sys.stderr)
|
||||
xt.print_exception()
|
||||
value = "(ERROR:{})".format(field)
|
||||
value = "{{BACKGROUND_RED}}{{ERROR:{}}}{{NO_COLOR}}".format(field)
|
||||
return value
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue