Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

#31: Add http error for 415 unsupported media type #32

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/Relax/Errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ extension RequestError {
case forbidden
/// 404 Not found
case notFound
/// 415 Unsupported media type
case unsupportedMediaType
/// 429 Too many requests
case tooManyRequests
/// 5XX Server error
Expand Down Expand Up @@ -107,6 +109,8 @@ extension RequestError {
self.type = .forbidden
case 404:
self.type = .notFound
case 415:
self.type = .unsupportedMediaType
case 429:
self.type = .tooManyRequests
case 500...599:
Expand Down
2 changes: 2 additions & 0 deletions Sources/URLMock/MockResponse/Response.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ extension MockResponse {
statusCode = 403
case .notFound:
statusCode = 404
case .unsupportedMediaType:
statusCode = 415
case .tooManyRequests:
statusCode = 429
case .server:
Expand Down
1 change: 1 addition & 0 deletions Tests/RelaxTests/Errors/HTTPErrorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ final class HTTPErrorTests: XCTestCase {
try checkHTTPError(statusCode: 401, type: .unauthorized)
try checkHTTPError(statusCode: 403, type: .forbidden)
try checkHTTPError(statusCode: 404, type: .notFound)
try checkHTTPError(statusCode: 415, type: .unsupportedMediaType)
try checkHTTPError(statusCode: 429, type: .tooManyRequests)
for code in 500...599 {
try checkHTTPError(statusCode: code, type: .server)
Expand Down