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

mongodb-js / mongodb-mcp-server / 18466847504

13 Oct 2025 01:09PM UTC coverage: 82.334% (+0.1%) from 82.186%
18466847504

Pull #642

github

web-flow
Merge fecc59b6c into 9d13e6b4d
Pull Request #642: feat: introduces drop-search-index tool MCP-239

1165 of 1543 branches covered (75.5%)

Branch coverage included in aggregate %.

89 of 89 new or added lines in 2 files covered. (100.0%)

2 existing lines in 1 file now uncovered.

5686 of 6778 relevant lines covered (83.89%)

68.92 hits per line

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

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

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

13
    static async fromResponse(
2✔
14
        response: Response,
5✔
15
        message: string = `error calling Atlas API`
5✔
16
    ): Promise<ApiClientError> {
5✔
17
        const err = await this.extractError(response);
5✔
18

19
        return this.fromError(response, err, message);
5✔
20
    }
5✔
21

22
    static fromError(
2✔
23
        response: Response,
12✔
24
        error?: ApiError | string | Error,
12✔
25
        message: string = `error calling Atlas API`
12✔
26
    ): ApiClientError {
12✔
27
        const errorMessage = this.buildErrorMessage(error);
12✔
28

29
        const apiError = typeof error === "object" && !(error instanceof Error) ? error : undefined;
12!
30

31
        return new ApiClientError(
12✔
32
            `[${response.status} ${response.statusText}] ${message}: ${errorMessage}`,
12✔
33
            response,
12✔
34
            apiError
12✔
35
        );
12✔
36
    }
12✔
37

38
    private static async extractError(response: Response): Promise<ApiError | string | undefined> {
2✔
39
        try {
5✔
40
            return (await response.json()) as ApiError;
5✔
41
        } catch {
5✔
42
            try {
3✔
43
                return await response.text();
3✔
44
            } catch {
3!
UNCOV
45
                return undefined;
×
UNCOV
46
            }
×
47
        }
3✔
48
    }
5✔
49

50
    private static buildErrorMessage(error?: string | ApiError | Error): string {
2✔
51
        let errorMessage: string = "unknown error";
12✔
52

53
        if (error instanceof Error) {
12!
54
            return error.message;
×
55
        }
×
56

57
        //eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check
58
        switch (typeof error) {
12✔
59
            case "object":
12✔
60
                errorMessage = error.reason || "unknown error";
9!
61
                if (error.detail && error.detail.length > 0) {
9✔
62
                    errorMessage = `${errorMessage}; ${error.detail}`;
8✔
63
                }
8✔
64
                break;
9✔
65
            case "string":
12!
66
                errorMessage = error;
3✔
67
                break;
3✔
68
        }
12✔
69

70
        return errorMessage.trim();
12✔
71
    }
12✔
72
}
2✔
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

© 2025 Coveralls, Inc