Re: no function clause matching became no case clause matching exception

"Michael P." <[email protected]>
Newsgroups gmane.comp.lang.erlang.general
Message-ID <20211213152218.4f68a5a6@aesop>
:-)

On Fri, 10 Dec 2021 16:30:23 +0100
Frans Schneider <[email protected]> wrote:

> The construct is used to process a list which should contain a mixture
> of #o{} and #oa{} records. If the list contains other types of records
> --which should never be the case--, it must fail. This is the actual code:
>
>      ATE_ids = [(fun(#oa{id = AT_id}) -> AT_id;
>                     (#o{id = AT_id}) -> AT_id end)(AT) || AT <- ATEs],

So far, to me "fail" means 'process dies' and 'no catching'.
When "function" or "case" in the exception matters, is there some `catch`?

    ATE_ids = [(fun (#oa{id = AT_id}) -> AT_id;
                    (#o{id = AT_id}) -> AT_id;
                    (Except) -> throw({myapp_unok, Except}) end)(AT)
               || AT <- ATEs],

If you can name it, you can claim it?

:-)

~Michael

--

The oldest, largest, most buggy piece of legacy
software in constant maintenance: human society.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.