Skip to content

Commit

Permalink
amendment: add NoNameservers and remove ValueError from squashed errors
Browse files Browse the repository at this point in the history
ValueError might be thrown by programming errors in
json handling, for example.
  • Loading branch information
katrinafyi committed Jul 20, 2024
1 parent de8be4d commit faf208b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mcstatus/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import dns.resolver
import sys
import json as _json
import argparse
Expand Down Expand Up @@ -143,11 +144,11 @@ def main(argv: list[str]) -> int:

args = parser.parse_args(argv)
lookup = JavaServer.lookup if not args.bedrock else BedrockServer.lookup
server = lookup(args.address)

try:
server = lookup(args.address)
return args.func(server)
except (socket.timeout, socket.gaierror, ValueError) as e:
except (socket.timeout, socket.gaierror, dns.resolver.NoNameservers) as e:
# catch and hide traceback for expected user-facing errors
print(f"Error: {e}", file=sys.stderr)
return 1
Expand Down

0 comments on commit faf208b

Please sign in to comment.