• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mongodb-js / mongodb-mcp-server / 14751702925

30 Apr 2025 09:47AM UTC coverage: 73.843%. First build
14751702925

Pull #176

github

fmenezes
fix: send error as error
Pull Request #176: fix: improve api error messages

154 of 283 branches covered (54.42%)

Branch coverage included in aggregate %.

10 of 13 new or added lines in 1 file covered. (76.92%)

628 of 776 relevant lines covered (80.93%)

39.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/src/common/atlas/apiClientError.ts
1
import { ApiError } from "./openapi.js";
2

3
export class ApiClientError extends Error {
4
    private constructor(
5
        message: string,
6
        public readonly response?: Response,
1✔
7
        public readonly body?: ApiError
1✔
8
    ) {
9
        super(message);
1✔
10
        this.name = "ApiClientError";
1✔
11
    }
12

13
    static async fromResponse(
14
        response: Response,
15
        message: string = `error calling Atlas API`
1✔
16
    ): Promise<ApiClientError> {
17
        let text: string = "";
1✔
18
        let body: ApiError | undefined = undefined;
1✔
19
        try {
1✔
20
            body = (await response.json()) as ApiError;
1✔
21
            text = body.reason || "unknown error";
1!
22
            if (body.detail && body.detail.length > 0) {
1✔
23
                text = `${text}; ${body.detail}`;
1✔
24
            }
25
        } catch {
NEW
26
            try {
×
27
                text = await response.text();
×
28
            } catch {
NEW
29
                text = "";
×
30
            }
31
        }
32

33
        if (text.length > 0) {
1!
34
            text = `${message}: [${response.status} ${response.statusText}] ${text.trim()}`;
1✔
35
        } else {
NEW
36
            text = `${message}: ${response.status} ${response.statusText}`;
×
37
        }
38

39
        return new ApiClientError(text, response, body);
1✔
40
    }
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc