mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 15:39:06 +01:00
Fix the error output in the python plugin to match LabeledError (#12575)
# Description Forgot to update this after updating the format of `LabeledError`. # Tests + Formatting Not applicable to the python plugin.
This commit is contained in:
parent
cc7b5c5a26
commit
999dfdf936
@ -121,7 +121,7 @@ def process_call(id, plugin_call):
|
|||||||
sys.stderr.write("\n")
|
sys.stderr.write("\n")
|
||||||
|
|
||||||
# Get the span from the call
|
# Get the span from the call
|
||||||
span = plugin_call["Run"]["call"]["head"]
|
span = plugin_call["call"]["head"]
|
||||||
|
|
||||||
# Creates a Value of type List that will be encoded and sent to Nushell
|
# Creates a Value of type List that will be encoded and sent to Nushell
|
||||||
f = lambda x, y: {
|
f = lambda x, y: {
|
||||||
@ -194,16 +194,25 @@ def write_response(id, response):
|
|||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
def write_error(id, msg, span=None):
|
def write_error(id, text, span=None):
|
||||||
"""
|
"""
|
||||||
Use this error format to send errors to nushell in response to a plugin call. The ID of the
|
Use this error format to send errors to nushell in response to a plugin call. The ID of the
|
||||||
plugin call is required.
|
plugin call is required.
|
||||||
"""
|
"""
|
||||||
error = {
|
error = {
|
||||||
"Error": {
|
"Error": {
|
||||||
"label": "ERROR from plugin",
|
"msg": "ERROR from plugin",
|
||||||
"msg": msg,
|
"labels": [
|
||||||
"span": span
|
{
|
||||||
|
"text": text,
|
||||||
|
"span": span,
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
} if span is not None else {
|
||||||
|
"Error": {
|
||||||
|
"msg": "ERROR from plugin",
|
||||||
|
"help": text,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write_response(id, error)
|
write_response(id, error)
|
||||||
@ -216,13 +225,13 @@ def handle_input(input):
|
|||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
elif input == "Goodbye":
|
elif input == "Goodbye":
|
||||||
return
|
exit(0)
|
||||||
elif "Call" in input:
|
elif "Call" in input:
|
||||||
[id, plugin_call] = input["Call"]
|
[id, plugin_call] = input["Call"]
|
||||||
if "Signature" in plugin_call:
|
if plugin_call == "Signature":
|
||||||
write_response(id, signatures())
|
write_response(id, signatures())
|
||||||
elif "Run" in plugin_call:
|
elif "Run" in plugin_call:
|
||||||
process_call(id, plugin_call)
|
process_call(id, plugin_call["Run"])
|
||||||
else:
|
else:
|
||||||
write_error(id, "Operation not supported: " + str(plugin_call))
|
write_error(id, "Operation not supported: " + str(plugin_call))
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user