cmd/earlyinit: improve error messages
Test / Create distribution (push) Successful in 1m1s
Test / Sandbox (push) Successful in 2m55s
Test / Hakurei (push) Successful in 4m20s
Test / ShareFS (push) Successful in 4m26s
Test / Sandbox (race detector) (push) Successful in 6m11s
Test / Hakurei (race detector) (push) Successful in 7m22s
Test / Flake checks (push) Successful in 1m12s

This improves readability, especially on a small display.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-06-28 18:01:51 +09:00
parent d96eecded0
commit cf7c34555c
2 changed files with 6 additions and 3 deletions
+3 -1
View File
@@ -7,6 +7,7 @@ package main
import ( import (
"context" "context"
"crypto/rand" "crypto/rand"
"io"
"log" "log"
"os" "os"
"os/signal" "os/signal"
@@ -51,13 +52,14 @@ func init() {
func fatal(v ...any) { func fatal(v ...any) {
log.Println(v...) log.Println(v...)
log.Println("unable to continue, please reboot and resolve the problem manually") log.Println("unable to continue, please reboot and resolve the problem manually")
log.SetOutput(io.Discard)
select {} select {}
} }
// must calls fatal with err if it is non-nil. // must calls fatal with err if it is non-nil.
func must(err error) { func must(err error) {
if err != nil { if err != nil {
log.Println(err) fatal(err)
select {} select {}
} }
} }
+3 -2
View File
@@ -26,8 +26,9 @@ var _ report.RepresentableError = ModprobeError{}
func (ModprobeError) Representable() {} func (ModprobeError) Representable() {}
func (e ModprobeError) Error() string { func (e ModprobeError) Error() string {
return fmt.Sprintf( return fmt.Sprintf(
"modprobe exit status %d: %s", "%s (exit status %d)",
e.ExitCode, strings.TrimSpace(e.Stderr), strings.TrimPrefix(strings.TrimSpace(e.Stderr), "modprobe: "),
e.ExitCode,
) )
} }