blob: 7baf91855c8ffd3ed20710fd8b375883c23f31ba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
//
// GitHubAPIError.swift
// octosentry
//
import Foundation
enum GitHubAPIError: Error, LocalizedError, Sendable {
case missingToken
case network(String)
case invalidResponse
case unauthorized
case forbidden
case notFound
case rateLimited
case httpError(status: Int)
case decodingFailed(String)
var errorDescription: String? {
switch self {
case .missingToken:
"No GitHub token found in the GITHUB_TOKEN environment variable."
case .network(let message):
"Network error: \(message)"
case .invalidResponse:
"Received an unexpected response from GitHub."
case .unauthorized:
"GitHub rejected the token (401 Unauthorized)."
case .forbidden:
"Token lacks permission for this alert type (403 Forbidden)."
case .notFound:
"Repository or endpoint not found (404)."
case .rateLimited:
"GitHub API rate limit exceeded (429)."
case .httpError(let status):
"GitHub API returned HTTP \(status)."
case .decodingFailed(let message):
"Failed to parse GitHub API response: \(message)"
}
}
}
|