@@ -564,6 +564,14 @@ defmodule BadStructError do
564
564
end
565
565
end
566
566
567
+ defmodule BadMapError do
568
+ defexception [ map: nil ]
569
+
570
+ def message ( exception ) do
571
+ "expected a map, got: #{ inspect ( exception . map ) } "
572
+ end
573
+ end
574
+
567
575
defmodule MatchError do
568
576
defexception [ term: nil ]
569
577
@@ -669,7 +677,12 @@ defmodule KeyError do
669
677
defexception key: nil , term: nil
670
678
671
679
def message ( exception ) do
672
- "key #{ inspect exception . key } not found in: #{ inspect exception . term } "
680
+ msg = "key #{ inspect exception . key } not found"
681
+ if exception . term != nil do
682
+ msg <> " in: #{ inspect exception . term } "
683
+ else
684
+ msg
685
+ end
673
686
end
674
687
end
675
688
@@ -767,6 +780,20 @@ defmodule ErlangError do
767
780
def normalize ( { :badmatch , term } , _stacktrace ) do
768
781
% MatchError { term: term }
769
782
end
783
+
784
+ # Erlang R18.0 changed this for various functions in the maps module
785
+ def normalize ( { :badmap , map } , _stacktrace ) do
786
+ % BadMapError { map: map }
787
+ end
788
+
789
+ # Erlang R18.0 changed this for various functions in the maps module
790
+ def normalize ( { :badkey , key } , stacktrace ) do
791
+ term = case stacktrace do
792
+ [ { :maps , :update , [ _ , _ , map ] , [ ] } | _ ] -> map
793
+ _ -> nil
794
+ end
795
+ % KeyError { key: key , term: term }
796
+ end
770
797
771
798
def normalize ( { :case_clause , term } , _stacktrace ) do
772
799
% CaseClauseError { term: term }
0 commit comments