diff --git a/app/src/main/java/com/termux/app/TermuxService.java b/app/src/main/java/com/termux/app/TermuxService.java index 71a4eb81..66d56eda 100644 --- a/app/src/main/java/com/termux/app/TermuxService.java +++ b/app/src/main/java/com/termux/app/TermuxService.java @@ -419,6 +419,11 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas TermuxTask newTermuxTask = TermuxTask.execute(this, executionCommand, this, false); if (newTermuxTask == null) { Logger.logError(LOG_TAG, "Failed to execute new TermuxTask command for:\n" + executionCommand.getCommandIdAndLabelLogString()); + // If the execution command was started for a plugin, then process the error + if (executionCommand.isPluginExecutionCommand) + PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false); + else + Logger.logStackTracesWithMessage(LOG_TAG, "(" + executionCommand.errCode + ") " + executionCommand.errmsg, executionCommand.throwableList); return null; } @@ -510,6 +515,11 @@ public final class TermuxService extends Service implements TermuxTask.TermuxTas TermuxSession newTermuxSession = TermuxSession.execute(this, executionCommand, getTermuxTerminalSessionClient(), this, sessionName, executionCommand.isPluginExecutionCommand); if (newTermuxSession == null) { Logger.logError(LOG_TAG, "Failed to execute new TermuxSession command for:\n" + executionCommand.getCommandIdAndLabelLogString()); + // If the execution command was started for a plugin, then process the error + if (executionCommand.isPluginExecutionCommand) + PluginUtils.processPluginExecutionCommandError(this, LOG_TAG, executionCommand, false); + else + Logger.logStackTracesWithMessage(LOG_TAG, "(" + executionCommand.errCode + ") " + executionCommand.errmsg, executionCommand.throwableList); return null; } diff --git a/termux-shared/src/main/java/com/termux/shared/shell/TermuxTask.java b/termux-shared/src/main/java/com/termux/shared/shell/TermuxTask.java index 1234284d..4507b30f 100644 --- a/termux-shared/src/main/java/com/termux/shared/shell/TermuxTask.java +++ b/termux-shared/src/main/java/com/termux/shared/shell/TermuxTask.java @@ -70,8 +70,11 @@ public final class TermuxTask { final String[] commandArray = ShellUtils.setupProcessArgs(executionCommand.executable, executionCommand.arguments); - if (!executionCommand.setState(ExecutionState.EXECUTING)) + if (!executionCommand.setState(ExecutionState.EXECUTING)) { + executionCommand.setStateFailed(ExecutionCommand.RESULT_CODE_FAILED, context.getString(R.string.error_failed_to_execute_termux_task_command, executionCommand.getCommandIdAndLabelLogString()), null); + TermuxTask.processTermuxTaskResult(null, executionCommand); return null; + } Logger.logDebug(LOG_TAG, executionCommand.toString());