From a2a291791c6447528d3b1abc1ec57c7b213730b6 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 15 Sep 2025 02:30:47 +0900 Subject: internal/sys: separate hsu uid cache This begins the effort of the removal of the sys package. Signed-off-by: Ophestra --- internal/app/errors.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'internal/app/errors.go') diff --git a/internal/app/errors.go b/internal/app/errors.go index 566103d4..f7fa2b1c 100644 --- a/internal/app/errors.go +++ b/internal/app/errors.go @@ -7,6 +7,7 @@ import ( "hakurei.app/container" "hakurei.app/hst" "hakurei.app/internal/hlog" + "hakurei.app/internal/sys" ) // PrintRunStateErr prints an error message via [log] if runErr is not nil, and returns an appropriate exit code. @@ -98,13 +99,20 @@ func PrintRunStateErr(rs *RunState, runErr error) (code int) { // TODO(ophestra): this duplicates code in cmd/hakurei/command.go, keep this up to date until removal func printMessageError(fallback string, err error) { - if m, ok := container.GetErrorMessage(err); ok { - if m != "\x00" { - log.Print(m) - } - } else { + // this indicates the error message has already reached stderr, outside the current process's control; + // this is only reached when hsu fails for any reason, as a second error message following hsu is confusing + if errors.Is(err, sys.ErrHsuAccess) { + hlog.Verbose("*"+fallback, err) + return + } + + m, ok := container.GetErrorMessage(err) + if !ok { log.Println(fallback, err) + return } + + log.Print(m) } // StateStoreError is returned for a failed state save. -- cgit v1.3.1