[erlang-questions] feedback please

Theepan vasdeveloper@REDACTED
Thu Sep 24 09:16:34 CEST 2015


>> So match or chrash is better ?

If something must not happen, and if happens crash. For example, for a
programers error it should crash. For off schema data it should crash. For
un-matching case clauses it should crash.

If something has a chance of happening, although it is expected, use
try-catch. Most of the time it is used at the inlets of a program where
unexpected inputs are possible. For example, user input.

And it is not uncommon to use try-catch and forced-crash together.

Theepan



On Thu, Sep 24, 2015 at 11:11 AM, Roelof Wobben <r.wobben@REDACTED> wrote:

> Op 24-9-2015 om 07:23 schreef zxq9:
>
>> On Thursday 24 September 2015 07:13:15 Roelof Wobben wrote:
>>
>>> Thanks for the feedback.
>>>
>>> I understand the code and I see you use error handling. That Is the next
>>> chapter I need to study.
>>> So after that chapter I can change it to the code you build.  But L like
>>> the way to handle the input a lot.
>>>
>> That was an example of match-or-crash as error handling. Any place that
>> code would have crashed is a place there wasn't a match, which meant
>> something deeper than our expected input case was faulty -- and in that
>> case it is better to stop execution and crash completely than carry on with
>> crazy data or a screwed up underlying runtime.
>>
>> If the next chapter covers "error handling" it probably talks about how
>> crashes are dealt with (and the link/monitor messages that are sent
>> whenever a process crashes/exits) and how to use `try.. catch` to handle
>> exceptions without crashing. There aren't very many places you will want to
>> use try..catch (many folks make a point of trying very hard not to use it,
>> myself included), but it is important to know.
>>
>> Have fun!
>> -Craig
>> _______________________________________________
>> erlang-questions mailing list
>> erlang-questions@REDACTED
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>> -----
>> Geen virus gevonden in dit bericht.
>> Gecontroleerd door AVG - www.avg.com
>> Versie: 2015.0.6140 / Virusdatabase: 4419/10690 - datum van uitgifte:
>> 09/24/15
>>
>>
>>
> Thanks,
>
> You are right. I did take a quick look and almost the whole chapter is try
> .. catch.  So match or chrash is better ?
>
> Roelof
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150924/286e7861/attachment.htm>


More information about the erlang-questions mailing list