Skip to content

Commit

Permalink
Apply lint errors
Browse files Browse the repository at this point in the history
Signed-off-by: Tomasz Pietrek <tomasz@nats.io>
  • Loading branch information
Jarema committed Apr 25, 2024
1 parent 4757d13 commit 25a1e89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions Sources/JetStream/context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extension JetStreamContext {

struct AckFuture {
var sub: NatsSubscription
//TODO(jrm): Add handling of all response errors (wrong expected sequence etc.)
func wait() async throws -> Ack {
guard let response = await sub.makeAsyncIterator().next() else {
throw JetStreamPublishError("broken pipe")
Expand Down
12 changes: 9 additions & 3 deletions Sources/JetStream/errors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@ import Foundation
struct JetStreamError: Codable {
var code: uint
//FIXME(jrm): This should be mapped to predefined JetStream errors from the server.
var err_code: ErrorCode
var errorCode: ErrorCode
var description: String?

enum CodingKeys: String, CodingKey {
case code = "code"
case errorCode = "err_code"
case description = "description"
}
}

struct ErrorCode: Codable {
Expand All @@ -26,7 +32,7 @@ struct ErrorCode: Codable {
static let clusterPeerNotMember = ErrorCode(rawValue: 10040)

/// Consumer expected to be ephemeral but detected a durable name set in subject
static let consumerephemeral_with_durable = ErrorCode(rawValue: 10019)
static let consumerEphemeralWithDurable = ErrorCode(rawValue: 10019)

/// Stream external delivery prefix overlaps with stream subject
static let streamExternalDeletePrefixOverlaps = ErrorCode(rawValue: 10022)
Expand Down Expand Up @@ -507,5 +513,5 @@ enum Response<T: Codable>: Codable {
}

func test() {
JetStreamError(code: 400, err_code: ErrorCode.accountResourcesExceeded, description: nil)
JetStreamError(code: 400, errorCode: ErrorCode.accountResourcesExceeded, description: nil)
}

0 comments on commit 25a1e89

Please sign in to comment.