Skip to content

Commit

Permalink
Remove MultipartMessageError
Browse files Browse the repository at this point in the history
  • Loading branch information
ptoffy committed Feb 26, 2025
1 parent 1ef0f45 commit 09a5b73
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
4 changes: 0 additions & 4 deletions Sources/MultipartKit/MultipartMessageError.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/MultipartKit/MultipartParser+parse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extension MultipartParser {
case .needMoreData:
// In synchronous parsing with all data provided upfront,
// needing more data indicates an incomplete/corrupted message
throw MultipartMessageError.unexpectedEndOfFile
throw MultipartParserError.unexpectedEndOfFile

case .error(let error):
throw error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extension StreamingMultipartParserAsyncSequence.AsyncIterator {
do {
next = try await iterator.next(isolation: actor)
} catch {
throw MultipartParserError.backingSequenceError(underlyingReason: "\(error)")
throw MultipartParserError.backingSequenceError(reason: "\(error)")
}
if let next {
parser.append(buffer: next)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ where BackingSequence.Element: MultipartPartBodyElement & RangeReplaceableCollec
do {
next = try await iterator.next()
} catch {
throw MultipartParserError.backingSequenceError(underlyingReason: "\(error)")
throw MultipartParserError.backingSequenceError(reason: "\(error)")
}
if let next {
parser.append(buffer: next)
Expand Down
8 changes: 4 additions & 4 deletions Tests/MultipartKitTests/ParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ struct ParserTests {
""".utf8
)

#expect(throws: MultipartMessageError.unexpectedEndOfFile) {
#expect(throws: MultipartParserError.unexpectedEndOfFile) {
_ = try MultipartParser<[UInt8]>(boundary: boundary)
.parse([UInt8](message))
}

let stream = makeParsingStream(for: message)
var iterator = StreamingMultipartParserAsyncSequence(boundary: boundary, buffer: stream).makeAsyncIterator()

await #expect(throws: MultipartMessageError.unexpectedEndOfFile) {
await #expect(throws: MultipartParserError.unexpectedEndOfFile) {
while (try await iterator.next()) != nil {}
}
}
Expand Down Expand Up @@ -216,15 +216,15 @@ struct ParserTests {
""".utf8
)

#expect(throws: MultipartMessageError.unexpectedEndOfFile) {
#expect(throws: MultipartParserError.unexpectedEndOfFile) {
_ = try MultipartParser<[UInt8]>(boundary: boundary)
.parse([UInt8](message))
}

let stream = makeParsingStream(for: message)
var iterator = StreamingMultipartParserAsyncSequence(boundary: boundary, buffer: stream).makeAsyncIterator()

await #expect(throws: MultipartMessageError.unexpectedEndOfFile) {
await #expect(throws: MultipartParserError.unexpectedEndOfFile) {
while (try await iterator.next()) != nil {}
}
}
Expand Down

0 comments on commit 09a5b73

Please sign in to comment.