diff --git a/packages/helpermodules/command.py b/packages/helpermodules/command.py
index 4fc3d5d207..3c9c7fe17a 100644
--- a/packages/helpermodules/command.py
+++ b/packages/helpermodules/command.py
@@ -963,16 +963,17 @@ def __enter__(self):
return None
def __exit__(self, exception_type, exception, exception_traceback) -> bool:
- if isinstance(exception, Exception):
+ if isinstance(exception, subprocess.CalledProcessError):
pub_user_message(self.payload, self.connection_id,
- f'Es ist ein interner Fehler aufgetreten: {exception}', MessageType.ERROR)
- log.error({traceback.format_exc()})
+ (f'Fehler-Status: {exception.returncode}
Meldung: '
+ f'{exception.stderr if exception.stderr else ""} '
+ f'{exception.output if exception.output else ""}'),
+ MessageType.ERROR)
return True
- elif isinstance(exception, subprocess.CalledProcessError):
- log.debug(exception.stdout)
+ elif isinstance(exception, Exception):
pub_user_message(self.payload, self.connection_id,
- f'Fehler-Status: {exception.returncode}
Meldung: {exception.stderr}',
- MessageType.ERROR)
+ f'Es ist ein interner Fehler aufgetreten: {exception}', MessageType.ERROR)
+ log.error({traceback.format_exc()})
return True
else:
return False
diff --git a/packages/helpermodules/utils/run_command.py b/packages/helpermodules/utils/run_command.py
index 3aa98f9473..cf8d963670 100644
--- a/packages/helpermodules/utils/run_command.py
+++ b/packages/helpermodules/utils/run_command.py
@@ -30,7 +30,9 @@ def run_command(command, process_exception: bool = False):
return result.stdout
except subprocess.CalledProcessError as e:
if process_exception:
- log.debug(e.stdout)
- log.exception(e.stderr)
+ if e.output is not None:
+ log.exception(e.output)
+ if e.stderr is not None:
+ log.exception(e.stderr)
else:
raise e