Skip to content

Commit 1edd49a

Browse files
author
Pavlos Parissis
committed
Return a more descriptive error message
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
1 parent ac01d79 commit 1edd49a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

haproxyadmin/haproxy.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ def __init__(self,
114114
for _file in glob.glob(os.path.join(socket_dir, '*')):
115115
if is_unix_socket(_file) and connected_socket(_file, timeout):
116116
socket_files.append(_file)
117-
elif (socket_file and is_unix_socket(socket_file) and
117+
elif (socket_file and not os.path.exists(socket_file)):
118+
raise ValueError("{} UNIX socket file was not found".format(socket_file))
119+
elif (socket_file and os.path.exists(socket_file) and is_unix_socket(socket_file) and
118120
connected_socket(socket_file, timeout)):
119121
socket_files.append(os.path.realpath(socket_file))
120122
else:

0 commit comments

Comments
 (0)