Wrong error handling and wrong `exitCode`
zvictor opened this issue · 1 comments
zvictor commented
Description
The way errors are handled by this tool make it near impossible to build other tools or scripts on top of it in a reliable manner.
As soon as an error is thrown, the script calling fauna
is broken.
Here is an example of intended behaviour, but that fails as soon as an error is thrown.
Steps to reproduce the error:
1- Copy the code below into /tmp/role.fql:
CreateRole({ name: "user",
membership: [{ resource: Collection('User') }],
privileges: [
{
resource: Function('logout'),
actions: { call: true }
}
]
})
2- Run the code below (or any code that would trigger a remote error within fauna
):
npx fauna eval --format=json --file=/tmp/role.fql && echo '\nSuccess! No error code!'
Output:
{
errors: [
...
...
]
}
Success! No error code!
Desired behaviour
- The
exitCode
should clearly never be0
when the output is an error (which would then not letSuccess! No error code!
be shown). - The error message should go in the
stderr
but instead goes instdout
. - The message has a JSON-like structure, but can't be parsed by any script because is not valid JSON.
echo-bravo-yahoo commented
Looks like this was largely resolved in #158 - going to close. Reopen if there's outstanding work.