{"modulePath":"github.com/github/github-mcp-server/v2","version":"v2.2.0","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errors\n\n## Functions\n\n```go\nfunc ContextWithGitHubErrors(ctx context.Context) context.Context\n```\nContextWithGitHubErrors updates or creates a context with a pointer to GitHub error information (to be used by middleware).\n\n```go\nfunc NewGitHubAPIErrorResponse(ctx context.Context, message string, resp *github.Response, err error) *mcp.CallToolResult\n```\nNewGitHubAPIErrorResponse returns an mcp.NewToolResultError and retains the error in the context for access via middleware\n\n```go\nfunc NewGitHubAPIErrorToCtx(ctx context.Context, message string, resp *github.Response, err error) (context.Context, error)\n```\n\n```go\nfunc NewGitHubAPIStatusErrorResponse(ctx context.Context, message string, resp *github.Response, body []byte) *mcp.CallToolResult\n```\nNewGitHubAPIStatusErrorResponse handles cases where the API call succeeds (err == nil) but returns an unexpected HTTP status code. It creates a synthetic error from the status code and response body, then records it in context for observability tracking.\n\n```go\nfunc NewGitHubGraphQLErrorResponse(ctx context.Context, message string, err error) *mcp.CallToolResult\n```\nNewGitHubGraphQLErrorResponse returns an mcp.NewToolResultError and retains the error in the context for access via middleware\n\n```go\nfunc NewGitHubGraphQLErrorToCtx(ctx context.Context, message string, err error) (context.Context, error)\n```\n\n```go\nfunc NewGitHubRawAPIErrorResponse(ctx context.Context, message string, resp *http.Response, err error) *mcp.CallToolResult\n```\nNewGitHubRawAPIErrorResponse returns an mcp.NewToolResultError and retains the error in the context for access via middleware\n\n```go\nfunc NewStructuredResolutionErrorResponse(err *StructuredResolutionError) *mcp.CallToolResult\n```\nNewStructuredResolutionErrorResponse returns an mcp.CallToolResult whose text body is the JSON-serialised StructuredResolutionError, suitable for agent self-correction.\n\n## Types\n\n```go\ntype GitHubAPIError struct {\n\tMessage  string           `json:\"message\"`\n\tResponse *github.Response `json:\"-\"`\n\tErr      error            `json:\"-\"`\n}\n```\n\n```go\nfunc GetGitHubAPIErrors(ctx context.Context) ([]*GitHubAPIError, error)\n```\nGetGitHubAPIErrors retrieves the slice of GitHubAPIErrors from the context.\n\n```go\nfunc (e *GitHubAPIError) Error() string\n```\n\n```go\ntype GitHubCtxErrors struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype GitHubErrorKey struct{}\n```\n\n```go\ntype GitHubGraphQLError struct {\n\tMessage string `json:\"message\"`\n\tErr     error  `json:\"-\"`\n}\n```\n\n```go\nfunc GetGitHubGraphQLErrors(ctx context.Context) ([]*GitHubGraphQLError, error)\n```\nGetGitHubGraphQLErrors retrieves the slice of GitHubGraphQLErrors from the context.\n\n```go\nfunc (e *GitHubGraphQLError) Error() string\n```\n\n```go\ntype GitHubRawAPIError struct {\n\tMessage  string         `json:\"message\"`\n\tResponse *http.Response `json:\"-\"`\n\tErr      error          `json:\"-\"`\n}\n```\n\n```go\nfunc GetGitHubRawAPIErrors(ctx context.Context) ([]*GitHubRawAPIError, error)\n```\nGetGitHubRawAPIErrors retrieves the slice of GitHubRawAPIErrors from the context.\n\n```go\nfunc (e *GitHubRawAPIError) Error() string\n```\n\n```go\ntype StructuredResolutionError struct {\n\tKind       string `json:\"error\"`\n\tName       string `json:\"name,omitempty\"`\n\tField      string `json:\"field,omitempty\"`\n\tCandidates []any  `json:\"candidates,omitempty\"`\n\tHint       string `json:\"hint,omitempty\"`\n}\n```\nStructuredResolutionError is a machine-readable error returned by name-resolution helpers (e.g. resolving a project field or single-select option by name). Agents can parse the JSON body to self-correct without re-prompting.\n\nKind values:\n\n  - \"field\\_not\\_found\"      — no project field matches the supplied name\n  - \"field\\_ambiguous\"      — more than one project field shares the supplied name\n  - \"option\\_not\\_found\"     — no option on the resolved single-select field matches\n  - \"option\\_ambiguous\"     — duplicate option names on the resolved field\n  - \"item\\_not\\_in\\_project\"  — the issue/PR exists but is not an item on the project\n  - \"wrong\\_field\\_type\"     — the named field is not the data type the caller expected\n\n```go\nfunc NewStructuredResolutionError(kind, name, hint string, candidates []any) *StructuredResolutionError\n```\nNewStructuredResolutionError constructs a StructuredResolutionError.\n\n```go\nfunc (e *StructuredResolutionError) Error() string\n```\nError implements the error interface; the message is the JSON body so that the downstream tool result also carries the structured payload as plain text.\n\n","path":"github.com/github/github-mcp-server/v2/pkg/errors","name":"errors","synopsis":"","isRedistributable":true}
