-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
lib: python.ts add exception type #21230
Conversation
Add exception type to handle cases when spawned python script exits with error.
6d28f73
to
4e7a000
Compare
I'm not really sure if the |
ok it can be Line 1399 in 9601aee
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgot to publish
pkg/lib/python.ts
Outdated
|
||
const pyinvoke = ["sh", "-ec", "exec $(command -v /usr/libexec/platform-python || command -v python3) -c \"$@\"", "--"]; | ||
|
||
export interface PythonExitStatus extends BasicError { | ||
exit_status: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be null
?
function ProcessError(options, name) {
this.problem = options.problem || null;
this.exit_status = options["exit-status"];
if (this.exit_status === undefined)
this.exit_status = null;
this.exit_signal = options["exit-signal"];
if (this.exit_signal === undefined)
this.exit_signal = null;
this.message = options.message;
if (this.message === undefined) {
if (this.problem)
this.message = cockpit.message(options.problem);
else if (this.exit_signal !== null)
this.message = cockpit.format(_("$0 killed with signal $1"), name, this.exit_signal);
else if (this.exit_status !== undefined)
this.message = cockpit.format(_("$0 exited with code $1"), name, this.exit_status);
Although seems like a bug? We set it to null if undefined and then do !== undefined
this is weird
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I have a feeling that it's a bug and instead it should be checking for this.exit_status !== null
`exit_status` won't be undefined as it is set to `null` when checked for undefined for the first time.
@@ -1407,7 +1407,7 @@ function factory() { | |||
this.message = cockpit.message(options.problem); | |||
else if (this.exit_signal !== null) | |||
this.message = cockpit.format(_("$0 killed with signal $1"), name, this.exit_signal); | |||
else if (this.exit_status !== undefined) | |||
else if (this.exit_status !== null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This added line is not executed by any test.
Add exception type to handle cases when spawned python script exits with error.