mirror of
https://github.com/onyx-and-iris/q3rcon-tui.git
synced 2026-02-26 03:09:09 +00:00
write an error message to the user if a command fails.
This commit is contained in:
parent
e87ca1d0e5
commit
316fa2bd5f
@ -2,7 +2,7 @@ import re
|
||||
from pathlib import Path
|
||||
from typing import Annotated, Type
|
||||
|
||||
from aioq3rcon import Client
|
||||
from aioq3rcon import Client, RCONError
|
||||
from loguru import logger
|
||||
from pydantic import AfterValidator, BeforeValidator
|
||||
from pydantic_settings import BaseSettings, CliSettingsSource, SettingsConfigDict
|
||||
@ -94,13 +94,20 @@ class RconApp(App):
|
||||
if settings.refresh_output:
|
||||
self.query_one('#response', RichLog).clear()
|
||||
|
||||
async with Client(settings.host, settings.port, settings.password) as client:
|
||||
try:
|
||||
async with Client(
|
||||
settings.host, settings.port, settings.password
|
||||
) as client:
|
||||
response = await client.send_command(
|
||||
self.query_one('#command', Input).value
|
||||
)
|
||||
self.query_one('#response', RichLog).write(
|
||||
self.remove_color_codes(response.removeprefix('print\n'))
|
||||
)
|
||||
except RCONError as e:
|
||||
self.query_one('#response', RichLog).write(
|
||||
f'{type(e).__name__}: Unable to connect to server: is the server running and are the host, port, and password correct? ({e})'
|
||||
)
|
||||
|
||||
self.query_one('#command', Input).value = ''
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user