1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import gleam/dynamic/decode.{type DecodeError}
import gleam/json.{type Json}
import gleam/list
pub type DecodeErrors = List(DecodeError)
pub type JsObject {
JsObject
}
pub type DBError {
DBError(Nil)
DBErrorMessage(e: String)
DBErrorJson(j: Json)
DBErrorDecode(es: DecodeErrors)
}
pub fn error_to_string(e: DBError) -> String {
case e {
DBErrorMessage(m) -> m
DBError(Nil) -> "db unknown error"
DBErrorJson(j) -> json.to_string(j)
DBErrorDecode(es) ->
list.fold(es, "", fn(s, e) {
s <> "\nExpect '" <> e.expected <> "' Found '" <> e.found <> "'"
})
}
}
pub type Function0(r) =
fn() -> r
pub type Function1(a, r) =
fn(a) -> r
pub type Function2(a, b, r) =
fn(a, b) -> r
pub type Function3(a, b, c, r) =
fn(a, b, c) -> r
pub type Function4(a, b, c, d, r) =
fn(a, b, c, d) -> r
pub type SqlFunction(f) {
SqlFunction(f: f, sql: String)
}
|