File tree Expand file tree Collapse file tree 2 files changed +18
-20
lines changed
src/elastic_transport/transport Expand file tree Collapse file tree 2 files changed +18
-20
lines changed Original file line number Diff line number Diff line change 1
1
name = " Elasticsearch"
2
2
uuid = " e586a49d-aa29-4ce5-8f91-fa4f824367bd"
3
3
authors = [" Egor Shmorgun <egor.shmorgun@opensesame.com>" ]
4
- version = " 0.2.0 "
4
+ version = " 0.2.1 "
5
5
6
6
[deps ]
7
7
CodecZlib = " 944b1d66-785c-5afd-91f1-9de20f533193"
8
8
Coverage = " a2441757-f6aa-5fb2-8edb-039e3f45d037"
9
9
Dates = " ade2ca70-3891-5945-98fb-dc099432e06a"
10
10
HTTP = " cd3eb016-35fb-5094-929b-558a96fad6f3"
11
- InteractiveUtils = " b77e0a4c-d291-57a0-90e8-8db25a27a240"
12
11
JSON = " 682c06a0-de6a-54ab-a142-c8b1cf79cde6"
13
12
Mocking = " 78c3b35d-d492-501b-9361-3d52fe80e533"
14
13
Retry = " 20febd7b-183b-5ae2-ac4a-720e7ce64774"
Original file line number Diff line number Diff line change @@ -52,27 +52,26 @@ const HTTP_STATUSES = Dict(
52
52
510 => :NotExtended
53
53
)
54
54
55
- foreach (values (HTTP_STATUSES)) do exception_name
56
- struct_expr = Meta. parse (
57
- """
58
- struct $exception_name <: ServerException
59
- status
60
- message::String
55
+ macro generate_exception_structures (http_statuses_dict)
56
+ dict = eval (http_statuses_dict)
57
+ # dict = HTTP_STATUSES
58
+ return Expr (:block , map (values (dict)) do exception_name
59
+ quote
60
+ struct $ exception_name <: ServerException
61
+ status
62
+ message:: String
63
+ end
61
64
end
62
- """
63
- )
64
-
65
- eval (struct_expr)
65
+ end ... )
66
66
end
67
67
68
- using InteractiveUtils : subtypes
68
+ @generate_exception_structures (HTTP_STATUSES)
69
69
70
- const CODE_TO_EXCEPTION = Dict (
71
- Symbol (Base. typename (t). name) => t
72
- for t in subtypes (ServerException)
73
- ) |> t_codes -> Dict (
74
- k => t_codes[v]
75
- for (k, v) in HTTP_STATUSES
76
- )
70
+ macro transform_exceptions_to_types (http_statuses_dict)
71
+ dict = eval (http_statuses_dict)
72
+ Dict (k => eval (v) for (k, v) in dict)
73
+ end
74
+
75
+ const CODE_TO_EXCEPTION = @transform_exceptions_to_types (HTTP_STATUSES)
77
76
78
77
const HOST_UNREACHABLE_EXCEPTIONS = [HTTP. TimeoutError, HTTP. ConnectError]
You can’t perform that action at this time.
0 commit comments