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
6f54baf608
commit
0f611790af
1 changed files with 2 additions and 2 deletions
|
|
@ -456,14 +456,14 @@ func (m *Manager) Close() error {
|
|||
"server": name,
|
||||
"error": err.Error(),
|
||||
})
|
||||
errs = append(errs, err)
|
||||
errs = append(errs, fmt.Errorf("server %s: %w", name, err))
|
||||
}
|
||||
}
|
||||
|
||||
m.servers = make(map[string]*ServerConnection)
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue