a81a450e7e
Merged into tinqs/studio: - cmd/tinqs-cli/ — tinqs-cli (Go binary, from bot/cli) - cmd/tea/ — Gitea CLI tool (from tinqs/cli-tea) - services/bot/ — Bot service (from tinqs-ltd/bot on git.arikigame.com) - services/admin/ — Admin panel (from tinqs/admin) - services/team-tool/ — Team Tool (from tinqs/team-tool) - services/proxy/ — tinqs-proxy (from bot/proxy) - web/landing/ — tinqs.com website (from tinqs/website) - web/docs/ — Platform docs (from tinqs/docs) - web/blog/ — Blog (placeholder) - runner/ — Ephemeral CI runner (from tinqs/runner) All source repos will be deleted after verification.
35 lines
921 B
Go
35 lines
921 B
Go
// Copyright 2021 The Gitea Authors. All rights reserved.
|
|
// Copyright 2021 The nektos/act Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package common
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type jobErrorContextKey string
|
|
|
|
const jobErrorContextKeyVal = jobErrorContextKey("job.error")
|
|
|
|
// JobError returns the job error for current context if any
|
|
func JobError(ctx context.Context) error {
|
|
val := ctx.Value(jobErrorContextKeyVal)
|
|
if val != nil {
|
|
if container, ok := val.(map[string]error); ok {
|
|
return container["error"]
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func SetJobError(ctx context.Context, err error) {
|
|
ctx.Value(jobErrorContextKeyVal).(map[string]error)["error"] = err
|
|
}
|
|
|
|
// WithJobErrorContainer adds a value to the context as a container for an error
|
|
func WithJobErrorContainer(ctx context.Context) context.Context {
|
|
container := map[string]error{}
|
|
return context.WithValue(ctx, jobErrorContextKeyVal, container)
|
|
}
|