diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-09-15 02:30:47 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-09-15 02:30:47 +0900 |
| commit | a2a291791c6447528d3b1abc1ec57c7b213730b6 (patch) | |
| tree | 4d4515976d798b461d8df358c272364c5cf0b2e1 /internal/app | |
| parent | 8690419c2d577a27efe3cfcafc39c05b7646926b (diff) | |
internal/sys: separate hsu uid cache
This begins the effort of the removal of the sys package.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app')
| -rw-r--r-- | internal/app/errors.go | 18 |
1 files changed, 13 insertions, 5 deletions
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. |
