<div dir="ltr"><span style="font-size:12.8px">>> So match or chrash is better ?</span><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">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.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">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.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">And it is not uncommon to use try-catch and forced-crash together.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Theepan</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 24, 2015 at 11:11 AM, Roelof Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Op 24-9-2015 om 07:23 schreef zxq9:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
On Thursday 24 September 2015 07:13:15 Roelof Wobben wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks for the feedback.<br>
<br>
I understand the code and I see you use error handling. That Is the next<br>
chapter I need to study.<br>
So after that chapter I can change it to the code you build. But L like<br>
the way to handle the input a lot.<br>
</blockquote>
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.<br>
<br>
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.<br>
<br>
Have fun!<br>
-Craig<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br>
<br></div></div><span class="">
-----<br>
Geen virus gevonden in dit bericht.<br>
Gecontroleerd door AVG - <a href="http://www.avg.com" rel="noreferrer" target="_blank">www.avg.com</a><br></span>
Versie: 2015.0.6140 / Virusdatabase: 4419/10690 - datum van uitgifte: 09/24/15<br>
<br>
<br>
</blockquote>
<br>
Thanks,<br>
<br>
You are right. I did take a quick look and almost the whole chapter is try .. catch. So match or chrash is better ?<span class="HOEnZb"><font color="#888888"><br>
<br>
Roelof</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org" target="_blank">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br></div>