Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubwro committed Jan 29, 2024
1 parent 9b327f6 commit a5c02f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/jetstream/api/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ function convert(::Type{Union{T, ApiError}}, msg::NATS.Msg) where { T <: ApiResp
pl = NATS.payload(msg)
pl = replace(pl, "0001-01-01T00:00:00Z" => "0001-01-01T00:00:00.000Z")
response = JSON3.read(pl)
throw_on_api_error(response)
StructTypes.constructfrom(T, response)
if haskey(response, :error)
StructTypes.constructfrom(ApiError, response.error)
else
StructTypes.constructfrom(T, response)
end
end
4 changes: 2 additions & 2 deletions src/jetstream/stream/manage.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Create a stream.
function stream_create(connection::NATS.Connection, config::StreamConfiguration; no_throw = false)
validate(config)
response = NATS.request(Union{StreamInfo, ApiError}, connection, "\$JS.API.STREAM.CREATE.$(config.name)", JSON3.write(config))
no_throw || response isa ApiError && throw(response)
no_throw || throw_on_api_error(response)
response
end

Expand All @@ -19,7 +19,7 @@ Update a stream.
function stream_update(connection::NATS.Connection, config::StreamConfiguration; no_throw = false)
validate(config)
response = NATS.request(Union{StreamInfo, ApiError}, connection, "\$JS.API.STREAM.UPDATE.$(config.name)", JSON3.write(config))
no_throw || response isa ApiError && throw(response)
no_throw || throw_on_api_error(response)
response
end

Expand Down

0 comments on commit a5c02f8

Please sign in to comment.