Skip to content

Commit d765780

Browse files
committed
better bluesky error messages
1 parent 63be97e commit d765780

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

gleam.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name = "midas_sdk"
2-
version = "0.5.0"
2+
version = "0.5.1"
33
target = "javascript"
44

55
description = "A bag of SDK's that can be used with midas."

src/midas/sdk/bluesky.gleam

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import gleam/bit_array
12
import gleam/dynamic/decode
23
import gleam/http
34
import gleam/http/request
45
import gleam/json
6+
import gleam/result
57
import gleam/string
68
import midas/task as t
79
import snag
@@ -34,7 +36,10 @@ pub fn create_session(handle, password) {
3436
Error(reason) ->
3537
Error(snag.new("failed to decode response " <> string.inspect(reason)))
3638
}
37-
_ -> Error(snag.new("Did not get a 200 response"))
39+
_ -> {
40+
let body = bit_array.to_string(response.body) |> result.unwrap("")
41+
Error(snag.new("Did not get a 200 response.\n" <> body))
42+
}
3843
})
3944
t.done(token)
4045
}
@@ -72,7 +77,10 @@ pub fn create_post(access_token, handle, text, at) {
7277
Error(reason) ->
7378
Error(snag.new("failed to decode response " <> string.inspect(reason)))
7479
}
75-
_ -> Error(snag.new("Did not get a 200 response"))
80+
_ -> {
81+
let body = bit_array.to_string(response.body) |> result.unwrap("")
82+
Error(snag.new("Did not get a 200 response.\n" <> body))
83+
}
7684
})
7785
t.done(uri)
7886
}

0 commit comments

Comments
 (0)