fix: gracefully explode of missing context

See #675
This commit is contained in:
2025-10-01 11:48:51 +02:00
parent 5af3c5f56e
commit 89d5fc91b0
2 changed files with 22 additions and 0 deletions

View File

@ -6,9 +6,11 @@ import (
"errors"
"net/http"
"os"
"path"
"strings"
"time"
"coopcloud.tech/abra/pkg/config"
contextPkg "coopcloud.tech/abra/pkg/context"
"coopcloud.tech/abra/pkg/i18n"
"coopcloud.tech/abra/pkg/log"
@ -41,6 +43,11 @@ func New(serverName string, opts ...Opt) (*client.Client, error) {
ctx, err := GetContext(serverName)
if err != nil {
serverDir := path.Join(config.SERVERS_DIR, serverName)
if _, err := os.Stat(serverDir); err == nil {
return nil, errors.New(i18n.G("server missing context, run \"abra server add %s\"?", serverName))
}
return nil, errors.New(i18n.G("unknown server, run \"abra server add %s\"?", serverName))
}