Skip to content
Discussion options

You must be logged in to vote

@seanmrich Can you explain what you're trying to achieve here? The library comes with a Codable.JSONRepresentation type for doing this kind of thing. Are you trying to do JSONB, instead?

I don't love using the force unwrap, but you could use withErrorReporting and return an empty [UInt8] if there's an error. Is there a better way?

Do you mean the force try!? The QueryBinding type has an invalid case for error handling:

extension MyValue.BytesRepresentation: QueryBindable {
  public var queryBinding: QueryBinding {
    do {
      return try .blob([UInt8](JSONEncoder().encode(queryOutput)))
    } catch {
      return .invalid(error)
    }
  }
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@seanmrich
Comment options

@aehlke
Comment options

@mbrandonw
Comment options

@aehlke
Comment options

Answer selected by stephencelis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants