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
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:
@@ -7,6 +7,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -51,13 +52,14 @@ func init() {
|
||||
func fatal(v ...any) {
|
||||
log.Println(v...)
|
||||
log.Println("unable to continue, please reboot and resolve the problem manually")
|
||||
log.SetOutput(io.Discard)
|
||||
select {}
|
||||
}
|
||||
|
||||
// must calls fatal with err if it is non-nil.
|
||||
func must(err error) {
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
fatal(err)
|
||||
select {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ var _ report.RepresentableError = ModprobeError{}
|
||||
func (ModprobeError) Representable() {}
|
||||
func (e ModprobeError) Error() string {
|
||||
return fmt.Sprintf(
|
||||
"modprobe exit status %d: %s",
|
||||
e.ExitCode, strings.TrimSpace(e.Stderr),
|
||||
"%s (exit status %d)",
|
||||
strings.TrimPrefix(strings.TrimSpace(e.Stderr), "modprobe: "),
|
||||
e.ExitCode,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user