Skip to content
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

Forward error to stderr and set exitCode #158

Merged
merged 2 commits into from
Apr 4, 2022
Merged

Conversation

zvictor
Copy link
Contributor

@zvictor zvictor commented Mar 8, 2022

This is a fix for #157 and improves the code added in #118.

Comment on lines 62 to 69
console.error(
util.inspect(JSON.parse(error.faunaError.requestResult.responseRaw), {
depth: null,
compact: false,
})
)

process.exit(1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather have something on the lines of:

Suggested change
console.error(
util.inspect(JSON.parse(error.faunaError.requestResult.responseRaw), {
depth: null,
compact: false,
})
)
process.exit(1)
console.error(JSON.stringify(JSON.parse(error.faunaError.requestResult.responseRaw), null, 2))
errorOut(new Error(`The query #${err.queryNumber} has failed`))

...but it's unclear to me why it's important to keep the consistency added in #118.

I would prefer having the ability to parse the errors than having it looking fancier.

Copy link
Contributor

@cleve-fauna cleve-fauna Apr 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @zvictor we're going to punt on making any calls on emitting parseable errors from the shell as we'd want to make that behavior consistent across the shell, and think carefully about making error formats part of the shell's contract.

I have pushed a tweak to this section however, that leverages errorOut and maintains the formating that was applied in #118 .

There's now a test to confirm the exit code as well.

@zvictor
Copy link
Contributor Author

zvictor commented Mar 20, 2022

@fireridlle @faunaee @parkhomenko is there anything else I can improve in this PR?

@aprilmintacpineda
Copy link

We need this, because currently fauna shell does not exit with error

image

@zvictor
Copy link
Contributor Author

zvictor commented Mar 28, 2022

I mentioned before but will keep repeating it over and over again:

I wish fauna had an open-source experience manager of sorts. Someone to represent the community inside the company.

It really sucks to make hard working contributions for a company that doesn't value them.

@cleve-fauna
Copy link
Contributor

I mentioned before but will keep repeating it over and over again:

I wish fauna had an open-source experience manager of sorts. Someone to represent the community inside the company.

It really sucks to make hard working contributions for a company that doesn't value them.

Hey @zvictor thanks for time and feedback and sorry we left you hanging for so long.

We are working on building some automation to get these issues in front of our dev team to do better in the future.

In the meantime, I'll be looking at this PR today as it does indeed look like something we need to do.

@cleve-fauna
Copy link
Contributor

Ah sorry working on fixing the mess I just made.

@cleve-fauna
Copy link
Contributor

cleve-fauna commented Apr 4, 2022

We need this, because currently fauna shell does not exit with error

image

Thanks for bringing up the same issue in the upload-graph-ql command @aprilmintacpineda. I've cut a separate issue to tract that: #180

@cleve-fauna cleve-fauna merged commit b3c4c94 into fauna:main Apr 4, 2022
@cleve-fauna
Copy link
Contributor

This will be released today.

@aprilmintacpineda
Copy link

Waiting for release!

@cleve-fauna
Copy link
Contributor

Waiting for release!

Its in 0.15.0 @aprilmintacpineda

@zvictor zvictor deleted the patch-1 branch June 9, 2022 18:29
@zvictor
Copy link
Contributor Author

zvictor commented Jun 9, 2022

Thank you @cleve-fauna! I can confirm that it works much better now, throwing the errors as expected.
I can now go back into working at zvictor/brainyduck#1.

If you feel that you can help me there as well, please don't feel shy 😊
It would be much appreciated! ❤️

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