mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 05:27:07 +08:00
monitor: improve error messages
Print more understandable messages on error: - When ps fails because the monitor doesn't attach to any session, print "no attaching session" instead of "unknown ref". - Avoid disconnect silently fails when the monitor doesn't attach to any session. Print "no attaching session" error instead. - Fix error message of "attach"'s arguments. ("server name must be passed" -> "ID of session or process must be passed") Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
@ -23,10 +23,16 @@ func (cm *DisconnectCmd) Exec(ctx context.Context, args []string) error {
|
||||
target := cm.m.AttachedSessionID()
|
||||
if len(args) >= 2 {
|
||||
target = args[1]
|
||||
} else if target == "" {
|
||||
return errors.Errorf("no attaching session")
|
||||
}
|
||||
isProcess, err := isProcessID(ctx, cm.m, target)
|
||||
if err == nil && isProcess {
|
||||
if err := cm.m.DisconnectProcess(ctx, cm.m.AttachedSessionID(), target); err != nil {
|
||||
sid := cm.m.AttachedSessionID()
|
||||
if sid == "" {
|
||||
return errors.Errorf("no attaching session")
|
||||
}
|
||||
if err := cm.m.DisconnectProcess(ctx, sid, target); err != nil {
|
||||
return errors.Errorf("disconnecting from process failed %v", target)
|
||||
}
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user