You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
117 lines
4.4 KiB
117 lines
4.4 KiB
<!DOCTYPE html> |
|
<html lang="en"> |
|
<head> |
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|
<meta http-equiv="content-type" content="text/html; charset=utf-8"> |
|
|
|
<!-- Enable responsiveness on mobile devices--> |
|
<!-- viewport-fit=cover is to support iPhone X rounded corners and notch in landscape--> |
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, viewport-fit=cover"> |
|
|
|
<title>Julio Biason .Me 4.3</title> |
|
|
|
<!-- CSS --> |
|
<link rel="stylesheet" href="https://blog.juliobiason.me/print.css" media="print"> |
|
<link rel="stylesheet" href="https://blog.juliobiason.me/poole.css"> |
|
<link rel="stylesheet" href="https://blog.juliobiason.me/hyde.css"> |
|
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700|Abril+Fatface"> |
|
|
|
|
|
|
|
|
|
|
|
</head> |
|
|
|
<body class=" "> |
|
|
|
<div class="sidebar"> |
|
<div class="container sidebar-sticky"> |
|
<div class="sidebar-about"> |
|
|
|
<a href="https://blog.juliobiason.me"><h1>Julio Biason .Me 4.3</h1></a> |
|
|
|
<p class="lead">Old school dev living in a 2.0 dev world</p> |
|
|
|
|
|
</div> |
|
|
|
<ul class="sidebar-nav"> |
|
|
|
|
|
<li class="sidebar-nav-item"><a href="/">English</a></li> |
|
|
|
<li class="sidebar-nav-item"><a href="/pt">Português</a></li> |
|
|
|
<li class="sidebar-nav-item"><a href="/tags">Tags (EN)</a></li> |
|
|
|
<li class="sidebar-nav-item"><a href="/pt/tags">Tags (PT)</a></li> |
|
|
|
|
|
</ul> |
|
</div> |
|
</div> |
|
|
|
|
|
<div class="content container"> |
|
|
|
<div class="post"> |
|
<h1 class="post-title">Things I Learnt The Hard Way - If You Know How To Handle It, Handle It</h1> |
|
<span class="post-date"> |
|
2019-06-24 |
|
|
|
<a href="https://blog.juliobiason.me/tags/books/">#books</a> |
|
|
|
<a href="https://blog.juliobiason.me/tags/things-i-learnt/">#things i learnt</a> |
|
|
|
<a href="https://blog.juliobiason.me/tags/exceptions/">#exceptions</a> |
|
|
|
<a href="https://blog.juliobiason.me/tags/error-handling/">#error handling</a> |
|
|
|
</span> |
|
<p>If you know an error can occur, then you should handle it properly, instead of |
|
ignoring it.</p> |
|
<span id="continue-reading"></span> |
|
<p>This is the opposite point of <a href="/books/things-i-learnt/crash-it">let it crash</a>: |
|
You're writing some code that you <em>know</em> it can crash in a certain way, what |
|
should you do? Well, the answer is simple: <em>handle</em> it, not <em>ignore</em> it.</p> |
|
<p>If we go back to the fact that Java will describe every single exception that |
|
can be thrown by a function, you should handle each exception, no excuses.</p> |
|
<p>If you're using Python, then you should capture the exceptions you know how to |
|
handle, no exceptions -- and tying with the previous point, if you don't know |
|
how to handle them, you should not capture them in the first place.</p> |
|
<p>But, no matter what language you're using, if you know an error/exception can |
|
occur, <em>deal with it</em>. If you have to save the content of the user somewhere |
|
else, log it to be reprocessed later or even just show an error message, do |
|
it.</p> |
|
<p>Although I seriously meant it, it doesn't mean you have to remember every |
|
single exception/error code and what it means when calling a function. You can |
|
write code that will actually go through the happy path and later fill the |
|
blanks. Or even, when you're working on another part of the code, if you |
|
remember another problem, just write on a post-it and add the handling later. |
|
The important bit is not to forget to handle it.</p> |
|
<div> |
|
|
|
<div style="float:left"> |
|
<< <a href="/books/things-i-learnt/crash-it">It's Better To Let The Application Crash Than Do Nothing</a> |
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div style="float:right"> |
|
<a href="/books/things-i-learnt/data-types">Types Say What You Data Is</a> >> |
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
</div> |
|
|
|
</body> |
|
|
|
</html>
|
|
|