Skip to content

Commit

Permalink
Return a more descriptive error message
Browse files Browse the repository at this point in the history
When socket_file is not found we return:
UNIX socket file was not set

which is not descriptive at all when the file is not found.

Let's fix that by catching the case where the file is not present
and return a better message
  • Loading branch information
Pavlos Parissis committed Mar 2, 2023
1 parent ac01d79 commit 1edd49a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion haproxyadmin/haproxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ def __init__(self,
for _file in glob.glob(os.path.join(socket_dir, '*')):
if is_unix_socket(_file) and connected_socket(_file, timeout):
socket_files.append(_file)
elif (socket_file and is_unix_socket(socket_file) and
elif (socket_file and not os.path.exists(socket_file)):
raise ValueError("{} UNIX socket file was not found".format(socket_file))
elif (socket_file and os.path.exists(socket_file) and is_unix_socket(socket_file) and
connected_socket(socket_file, timeout)):
socket_files.append(os.path.realpath(socket_file))
else:
Expand Down

0 comments on commit 1edd49a

Please sign in to comment.