Skip to content

Commit

Permalink
Merge pull request #110 from mikpe/otp21-cleanups
Browse files Browse the repository at this point in the history
Otp21 cleanups
  • Loading branch information
mikpe authored Feb 22, 2022
2 parents dff165b + ececc49 commit 368899d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 45 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 2.9.5
- Removed workarounds for OTP < 21
- Add map() to the avro:out() union type
* 2.9.4
- Dropped `?MODULE` from required error in erlavro.hrl to allow elixir to extract record details
* 2.9.3
Expand Down
1 change: 0 additions & 1 deletion include/avro_internal.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
-define(AVRO_INTERNAL_HRL, true).

-include("erlavro.hrl").
-include("avro_stacktrace.hrl").

-define(INT4_MIN, -2147483648).
-define(INT4_MAX, 2147483647).
Expand Down
35 changes: 0 additions & 35 deletions include/avro_stacktrace.hrl

This file was deleted.

5 changes: 2 additions & 3 deletions src/avro_decoder_hooks.erl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
]).

-include("erlavro.hrl").
-include("avro_stacktrace.hrl").

-define(PD_PP_INDENTATION, '$avro_decoder_pp_indentation').
-define(PD_DECODER_HIST, '$avro_decoder_hist').
Expand Down Expand Up @@ -174,12 +173,12 @@ print_trace_on_failure(T, Sub, Data, DecodeFun, PrintFun, HistCount) ->
try
decode_and_add_trace(Sub, Data, DecodeFun)
catch
C : R ?CAPTURE_STACKTRACE
C : R : Stacktrace
when not (is_tuple(R) andalso element(1, R) =:= ?REASON_TAG) ->
%% catch only the very first error
ok = print_trace(PrintFun, HistCount),
ok = erase_hist(),
erlang:raise(C, {?REASON_TAG, R}, ?GET_STACKTRACE)
erlang:raise(C, {?REASON_TAG, R}, Stacktrace)
end.

%% @private
Expand Down
4 changes: 2 additions & 2 deletions src/avro_map.erl
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ encode(Type, Value, EncodeFun) ->
try
EncodeFun(ItemsType, K, V)
catch
C : E ?CAPTURE_STACKTRACE ->
C : E : Stacktrace ->
?RAISE_ENC_ERR(C, E, [{map, Type},
{key, K}], ?GET_STACKTRACE)
{key, K}], Stacktrace)
end
end, Value).

Expand Down
8 changes: 4 additions & 4 deletions src/avro_record.erl
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ do_default(FullName, FieldName, DoFun, Value) ->
try
DoFun(Value)
catch
error : Reason ?CAPTURE_STACKTRACE ->
error : Reason : Stacktrace ->
Context = [ {record, FullName}
, {field, FieldName}
, {reason, Reason}
],
erlang:raise(error, {bad_default, Context}, ?GET_STACKTRACE)
erlang:raise(error, {bad_default, Context}, Stacktrace)
end.

%% @private default value for a union type should be type checked by the
Expand Down Expand Up @@ -353,9 +353,9 @@ encode(#avro_record_type{ fields = FieldDefs
Value =:= ?NO_VALUE andalso erlang:error(required_field_missed),
EncodeFun(FieldName, FieldType, Value)
catch
C : E ?CAPTURE_STACKTRACE ->
C : E : Stacktrace ->
?RAISE_ENC_ERR(C, E, [{record, FullName},
{field, FieldName}], ?GET_STACKTRACE)
{field, FieldName}], Stacktrace)
end
end, FieldDefs).

Expand Down

0 comments on commit 368899d

Please sign in to comment.