fix(mcp): include server name and cause in Close() errors
Previously Close() discarded all underlying errors and returned only 'failed to close N server(s)', making debugging impossible. Now each error wraps the server name and original cause, and all errors are joined so callers can inspect the full failure list.
This commit is contained in:
parent
33058b534e
commit
d2b3fc1dd0
1 changed files with 2 additions and 2 deletions
|
|
@ -456,14 +456,14 @@ func (m *Manager) Close() error {
|
||||||
"server": name,
|
"server": name,
|
||||||
"error": err.Error(),
|
"error": err.Error(),
|
||||||
})
|
})
|
||||||
errs = append(errs, err)
|
errs = append(errs, fmt.Errorf("server %s: %w", name, err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m.servers = make(map[string]*ServerConnection)
|
m.servers = make(map[string]*ServerConnection)
|
||||||
|
|
||||||
if len(errs) > 0 {
|
if len(errs) > 0 {
|
||||||
return fmt.Errorf("failed to close %d server(s)", len(errs))
|
return fmt.Errorf("failed to close %d server(s): %w", len(errs), errors.Join(errs...))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue