fix(cli): keep the next step when an error's cause has several lines (#67)

A failed docker run with more than one line of output lost its 'floci doctor' hint, and a profile or Compose file that does not parse was reported with the parser's source-location line instead of what to do. Causes are now shown as one line, and docker's own output always gets its next step.

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-10-11 21:17:28 -05:00
1 parent 68d28d49ef
commit 188aa23edc
13 files changed
+149 -28

No files matched your search

@@ -3,6 +3,7 @@ package io.floci.cli.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import io.floci.cli.output.Ansi;
import io.floci.cli.util.Causes;
import java.io.IOException;
import java.nio.file.Files;
@@ -75,7 +76,7 @@ public class ProfileStore {
// The cause is quoted, not guessed: this is a parse error or a
// file that could not be opened.
System.err.println(Ansi.yellow("Warning: ") + "Could not read profile file " + p
+ ": " + firstLine(e.getMessage())
+ ": " + Causes.firstLine(e)
+ "\nCheck the file and its permissions, or delete it.");
}
});
@@ -89,12 +90,6 @@ public class ProfileStore {
return Optional.of(read(file));
}
private static String firstLine(String message) {
if (message == null) return "unreadable";
int newline = message.indexOf('\n');
return newline >= 0 ? message.substring(0, newline) : message;
}
// The one read path, so list and show agree on a profile's name.
private static Profile read(Path file) throws IOException {
Profile profile = YAML.readValue(file.toFile(), Profile.class);