Why does this work well:
% (1)
try
throw({abcd456, {aaa, "Name666"}})
catch
%% no need for throw:{abcd456, {aaa, FieldName}} ->
{abcd456, {aaa, FieldName}} ->
io:format("Caught an error: ~p~n", [FieldName])
end.
===>
Caught an error: "Name666"
ok
whereas this does require “type:<matched_error_info>” syntax, as it must:
% (2)
try
error({abcd456, {aaa, "Name777"}})
catch
error:{abcd456, {aaa, FieldName}} ->
io:format("Caught an error: ~p~n", [FieldName])
end.
?
In other words, why does the (1) work without “:” ? Isn’t this in odds with the documentation?