failed with error code 32" #724

Open
Aendrew87 opened this Issue Jul 27, 2016 · 5 comments

Projects

None yet

3 participants

@Aendrew87
Aendrew87 commented Jul 27, 2016 edited

psql -U postgres -c "\q"
if [ $? != 0 ]
then
echo "PostgreSQL database connection failed with error code 32"
exit 1
fi
why is there a static error 32?
i think it would be better to use the real error.

Source: https://raw.githubusercontent.com/RestyaPlatform/board/master/restyaboard.sh

@Aendrew87

there are about 60 cases where static error codes are used

@rrjanbiah
Contributor

@Aendrew87 Thanks for a very nice catch.

@lmarikannan
Contributor

@Aendrew87 Actually we are getting output for the command in integer format. If the command ran successfully then it returns 0. If its failed then it returns some integer like 2 (refer #775), 100 (refer #785). So shall we return their own error codes instead of hardcoded by us?

@Aendrew87

@lmarikannan with your hardcoded error codes it is difficult to get the real error. If you use the returned error code from the call it could be easier to get the reason for this issue.
So my suggestion was to use the real error code.
If there is duplicate output it would be difficult to find the part which failed.

Maybe the best solution is to output a static number and the real error code.
The static number to get the right command in the script and the real error code to search for the reason.
For example the output could be:
PostgreSQL database connection failed with error code $? (installscript static error code 32)

@lmarikannan
Contributor

@Aendrew87 Thank you very much for your suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment