Handle errors in /version command

This commit is contained in:
Davte 2020-02-20 11:14:51 +01:00
parent 4487034c7d
commit 2448c45c3d
2 changed files with 4 additions and 3 deletions

View File

@ -14,7 +14,7 @@ __author__ = "Davide Testa"
__email__ = "davide@davte.it" __email__ = "davide@davte.it"
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"] __credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
__license__ = "GNU General Public License v3.0" __license__ = "GNU General Public License v3.0"
__version__ = "2.4.7" __version__ = "2.4.8"
__maintainer__ = "Davide Testa" __maintainer__ = "Davide Testa"
__contact__ = "t.me/davte" __contact__ = "t.me/davte"

View File

@ -782,11 +782,12 @@ async def _version_command(bot, update, user_record):
try: try:
_subprocess = await asyncio.create_subprocess_exec( _subprocess = await asyncio.create_subprocess_exec(
'git', 'rev-parse', 'HEAD', 'git', 'rev-parse', 'HEAD',
stdout=asyncio.subprocess.PIPE stdout=asyncio.subprocess.PIPE,
stderr=asyncio.subprocess.PIPE
) )
stdout, stderr = await _subprocess.communicate() stdout, stderr = await _subprocess.communicate()
if stderr is not None: if stderr is not None:
raise stderr raise Exception(stderr.decode().strip())
version = stdout.decode().strip() version = stdout.decode().strip()
except Exception as e: except Exception as e:
return f"{e}" return f"{e}"