skip to content
Alvin Lucillo

Deleting vhost exit code

/ 1 min read

If you try to delete a non-existing vhost, you will still get a non-zero exit code. This is important because in your code (e.g., Go), you may not be expecting an error because manual execution doesn’t show an error, but this should be handled this results to an error.

Not showing the exit code

rabbitmqctl delete_vhost pipe1
Deleting vhost "pipe1" ...
Virtual host 'pipe1' does not exist

Showing the exit code

out=$(rabbitmqctl delete_vhost vhost1 2>&1); code=$?; echo "output: $out | exit code: $code"
output: Deleting vhost "vhost1" ...
Virtual host 'pipe1' does not exist | exit code: 65