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:
Devyn Cairns 2024-04-18 18:01:35 -07:00 committed by GitHub
parent cc7b5c5a26
commit 999dfdf936
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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: