public void ThrowOnError(string line)
{
if (!this.ParsesErrors)
{
if (line.EndsWith(": not found"))
{
Log.Warn(Tag, $"The remote execution returned: '{line}'");
throw new FileNotFoundException($"The remote execution returned: '{line}'");
}
if (line.EndsWith("No such file or directory"))
{
Log.Warn(Tag, $"The remote execution returned: {line}");
throw new FileNotFoundException($"The remote execution returned: '{line}'");
}
// for "unknown options"
if (line.Contains("Unknown option"))
{
Log.Warn(Tag, $"The remote execution returned: {line}");
throw new UnknownOptionException($"The remote execution returned: '{line}'");
}
// for "aborting" commands
if (line.IsMatch("Aborting.$"))
{
Log.Warn(Tag, $"The remote execution returned: {line}");
throw new CommandAbortingException($"The remote execution returned: '{line}'");
}
// for busybox applets
// cmd: applet not found
if (line.IsMatch("applet not found$"))
{
Log.Warn(Tag, $"The remote execution returned: '{line}'");
throw new FileNotFoundException($"The remote execution returned: '{line}'");
}
// checks if the permission to execute the command was denied.
// workitem: 16822
if (line.IsMatch("(permission|access) denied$"))
{
Log.Warn(Tag, $"The remote execution returned: '{line}'");
throw new PermissionDeniedException($"The remote execution returned: '{line}'");
}
}
}