aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/app.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-12 06:46:12 +0900
committerOphestra <cat@gensokyo.uk>2025-09-12 06:52:35 +0900
commitf8760438446ee4210a479402d91018ad610bcf34 (patch)
treeab8b3a1cbf69d2c2f42531fd786a480ca87f889e /internal/app/app.go
parent6265aea73a5f4933f4837bc1298c22fcd39b6f4f (diff)
internal/hlog: remove error wrapping
This was a stopgap solution that lasted for way too long. This finally removes it and prepares internal/app for some major changes. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/app.go')
-rw-r--r--internal/app/app.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/app/app.go b/internal/app/app.go
index 2039213c..dd34cf62 100644
--- a/internal/app/app.go
+++ b/internal/app/app.go
@@ -12,6 +12,7 @@ import (
"hakurei.app/internal/sys"
)
+// New returns the address of a newly initialised [App] struct.
func New(ctx context.Context, os sys.State) (*App, error) {
a := new(App)
a.sys = os
@@ -24,6 +25,7 @@ func New(ctx context.Context, os sys.State) (*App, error) {
return a, err
}
+// MustNew calls [New] and panics if an error is returned.
func MustNew(ctx context.Context, os sys.State) *App {
a, err := New(ctx, os)
if err != nil {
@@ -32,6 +34,7 @@ func MustNew(ctx context.Context, os sys.State) *App {
return a
}
+// An App keeps track of the hakurei container lifecycle.
type App struct {
outcome *Outcome
@@ -46,7 +49,7 @@ func (a *App) ID() state.ID { a.mu.RLock(); defer a.mu.RUnlock(); return a.id.un
func (a *App) String() string {
if a == nil {
- return "(invalid app)"
+ return "<nil>"
}
a.mu.RLock()
@@ -54,12 +57,12 @@ func (a *App) String() string {
if a.outcome != nil {
if a.outcome.user.uid == nil {
- return fmt.Sprintf("(sealed app %s with invalid uid)", a.id)
+ return "<invalid>"
}
- return fmt.Sprintf("(sealed app %s as uid %s)", a.id, a.outcome.user.uid)
+ return fmt.Sprintf("sealed app %s as uid %s", a.id, a.outcome.user.uid)
}
- return fmt.Sprintf("(unsealed app %s)", a.id)
+ return fmt.Sprintf("unsealed app %s", a.id)
}
// Seal determines the [Outcome] of [hst.Config].
@@ -69,7 +72,7 @@ func (a *App) Seal(config *hst.Config) (*Outcome, error) {
defer a.mu.Unlock()
if a.outcome != nil {
- panic("app sealed twice")
+ panic("attempting to seal app twice")
}
seal := new(Outcome)