<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="335659" data-post-id="335659">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Hermanverschooten" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Hermanverschooten/120/6447_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Hermanverschooten
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I would stick to your first version. It is clear what the returned errors are, the code is clean and concise.<br>
Introducing functions to have functions is overkill.<br>
The idea behind the anti-pattern is when you have multiple functions returning the same error tuples for different situations.  If you have 2 fetch functions that both return <code>{:error, :not_found}</code> then you don’t know where it came from, that has to be avoided.<br>
Therefore the suggestion is to return distinct tuples, which you already do.</p>
<p>It will always be a matter of taste. I for example have a <code>with</code> clause with 9 different <code>else</code>-clauses but they all differ and are clear where they originate.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="335659" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-335659" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="335659"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="335661" data-post-id="335661">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="tfwright" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/tfwright/120/20299_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  tfwright
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="Hermanverschooten" data-post="12" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/hermanverschooten/48/6447_2.png" class="avatar"> Hermanverschooten:</div>
<blockquote>
<p>It will always be a matter of taste.</p>
</blockquote>
</aside>
<p>I think this is right, and this kind of a thing is a challenge with a lot of anti-patterns. Lots of clauses adds complexity, but so do functions, so it’s not the case that simply replacing one with the other will always result in simpler code that all experienced developers agree is better/more maintainable. I know Jose has been trying to pare down that list to just the most important and objective pain points, but I almost feel like the top of that doc needs a big YMMV so people new to Elixir don’t take it <em>too</em> seriously and worse, try to use it as a club against other devs.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="335661" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-335661" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="335661"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="336005" data-post-id="336005">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="cheerfulstoic" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cheerfulstoic/120/3870_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  cheerfulstoic
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="gregvaughn" data-post="8" data-topic="65163" data-full="true">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>In this case, I’d have the helper functions return a 3-tuple in the error case, e.g. <code>{:error, status_code, message}</code> and a single <code>else</code> block to update the <code>conn</code></p>
</blockquote>
</aside>
<p>I would go so far as to say that you should <em>never</em> return 3-tuples when returning ok/error results.  In this case it’s high-level in a controller, so maybe this is best-case for it, but oftentimes when the error is returned you might end up with an error handler five levels up where the 3-tuple was passed up and the higher level code is (reasonably) expecting just <code>{:ok, _}</code> or <code>{:error, _}</code>.  <em>Much</em> better habit to always stick to those two patterns and if you need two bits then putting a tuple in your error like <code>{:error, {_, _}}</code>.</p>
<p>But another possibility, if you’re getting that complex, is to return an exception struct as the value in your error tuple (a pattern used by libraries like httpoison, mint, postgrex, and others).  If you do that relatively often then you can look for them and call <code>Exception.message</code> to get a string while keeping the error logic inside of the exception struct module.</p>
<hr>
<p>I also support the original code, by the way.  Much better to have <code>parse_id</code> / <code>fetch_book</code> be focused on one thing rather than two things (vis-a-vis separation-of-concerns).</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336005" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-336005" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336005"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="336006" data-post-id="336006">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="D4no0" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/D4no0/120/33624_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  D4no0
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>What I usually do is use fallback controller using <a href="https://hexdocs.pm/phoenix/Phoenix.Controller.html#action_fallback/1" rel="noopener nofollow ugc">action_fallback/1</a> for this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">defmodule MyFallbackController do
  use Phoenix.Controller

  def call(conn, {:error, :not_found}) do
    conn
    |&gt; put_status(:not_found)
    |&gt; put_view(MyErrorView)
    |&gt; render(:"404")
  end

  def call(conn, {:error, :unauthorized}) do
    conn
    |&gt; put_status(:forbidden)
    |&gt; put_view(MyErrorView)
    |&gt; render(:"403")
  end
end
</code></pre>
<p>In this way you have a single place where you handle all the potential errors and you can use <code>with</code> in your codebase without any concerns on intermediate error handling. As long as your return value != <code>conn</code> from your plugs, the fallback action will be always triggered.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336006" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-336006" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336006"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="336039" data-post-id="336039">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gregvaughn" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/120/954_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gregvaughn
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="cheerfulstoic" data-post="14" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cheerfulstoic/48/3870_2.png" class="avatar"> cheerfulstoic:</div>
<blockquote>
<p>I would go so far as to say that you should <em>never</em> return 3-tuples when returning ok/error results.</p>
</blockquote>
</aside>
<p>I’m not willing to go that dogmatic, but otherwise, yeah, i generally agree with you. I’ve felt that pain and I even gave an ElixirConf talk a couple of years ago about exceptions and advocated the <code>{:error, exception}</code> approach.</p>
<p>I’d be equally happy with <code>{:error, {status_code, message}}</code> in this isolated situation.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336039" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-336039" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336039"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="336040" data-post-id="336040">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="zachdaniel" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/zachdaniel/120/31980_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  zachdaniel
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Creator of Ash</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>I would actually prefer something like this:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">  def book(conn, %{"id" =&gt; id}) do
    with {:ok, id} &lt;- parse_id(id),
         {:ok, book} &lt;- fetch_book(id) do
      render_pretty_json(conn, book)
    else
      {:error, error} -&gt;
        handle_error(conn, error)
    end
  end

  defp handle_error(conn, :bad_request) do
    conn
     |&gt; put_status(:bad_request)
     |&gt; json(%{error: "Invalid ID"})
  end
        
  defp handle_error(conn, :not_found) do
    conn
    |&gt; put_status(:not_found)
    |&gt; json(%{error: "Book not found"})
  end
</code></pre>
<p>My reasoning:</p>
<ol>
<li>you have two simple functions, a happy path function and a sad path function, instead of one function handling both.</li>
<li>I wouldn’t want the functions returning errors to tell me what their status is. Their job is to do the thing or tell me something went wrong, not to provide an HTTP status. Thats the controller action’s job.</li>
<li>it lets the programmer looking at the code not think about errors if they aren’t what they are here for, but they can see where errors are handled.</li>
</ol> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336040" data-batch-url="/posts/batch_likers">
                        7
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-336040" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336040"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="336051" data-post-id="336051">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="gregvaughn" data-post="16" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>I’d be equally happy with <code>{:error, {status_code, message}}</code> in this isolated situation.</p>
</blockquote>
</aside>
<p>I am happy with that whenever (call me dogmatic if you like <img src="https://forum.elixirforum.com/uploads/default/original/2X/1/126cb0df7fa700c0fc3f99aa44138904e8fa3bf1.gif?v=15" title=":icon_wink:" class="emoji emoji-custom" alt=":icon_wink:" loading="lazy" width="20" height="20">). I have found that strictly adhering to two-tuples for results (ok / error) and then deconstructing the 2nd element if/when the need calls for it leads to much more predictable code.</p>
<p>The complexity involved in manually emulating exhaustive pattern matching – something that Erlang / Elixir sadly don’t have at compile-time – spirals out of control (and of the grasp of the human brain) extremely quickly. Some dogma is actually pragmatic and very helpful there.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336051" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-336051" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336051"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="336054" data-post-id="336054">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="gregvaughn" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/120/954_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  gregvaughn
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="dimitarvp" data-post="18" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>(call me dogmatic if you like <img src="https://forum.elixirforum.com/uploads/default/original/2X/1/126cb0df7fa700c0fc3f99aa44138904e8fa3bf1.gif?v=15" title=":icon_wink:" class="emoji emoji-custom" alt=":icon_wink:" loading="lazy" width="20" height="20">)</p>
</blockquote>
</aside>
<aside class="quote no-group" data-username="dimitarvp" data-post="18" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/48/38664_2.png" class="avatar"> dimitarvp:</div>
<blockquote>
<p>Some dogma is actually pragmatic and very helpful there.</p>
</blockquote>
</aside>
<p>I hope my initial statement didn’t come off harsh. There’s a little rebellious voice in my head that reacts when people say “always do …” or “never do …” and it looks for situations when that advice is unwise.</p>
<p>If I saw the original code in a PR I was reviewing, I wouldn’t even comment on it. It’s good enough and isolated within a single module. If you’re really feeling the pain of diverse patterns of result tuples (and I have worked in such systems), then I advise custom exception structs. Plus you can use those module to house additional error management functions if desired. I won’t advise to <em>always</em> use <code>{:error, exception}</code> pattern because it’s overhead and there’s tradeoffs to consider.</p>
<p>Understanding that there are tradeoffs in any specific circumstance is what I consider pragmatic. I’d even argue that once an anti-pattern is identified, it doesn’t automatically mean not to do it. Sometimes it can be justified in a given situation.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336054" data-batch-url="/posts/batch_likers">
                        3
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-336054" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336054"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="336056" data-post-id="336056">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="dimitarvp" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/120/38664_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  dimitarvp
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="gregvaughn" data-post="19" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>I hope my initial statement didn’t come off harsh.</p>
</blockquote>
</aside>
<p>It absolutely did not, I just felt the sudden urge to joke with you. <img src="https://forum.elixirforum.com/images/emoji/apple/smiley.png?v=15" title=":smiley:" class="emoji" alt=":smiley:" loading="lazy" width="20" height="20"></p>
<aside class="quote no-group" data-username="gregvaughn" data-post="19" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>There’s a little rebellious voice in my head that reacts when people say “always do …” or “never do …” and it looks for situations when that advice is unwise.</p>
</blockquote>
</aside>
<p>Exactly the same here, and as I get older I wish I was less rebellious or, to put it in an even better perspective – wish I knew when to be and when not to be.</p>
<aside class="quote no-group" data-username="gregvaughn" data-post="19" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>If you’re really feeling the pain of diverse patterns of result tuples (and I have worked in such systems), then I advise custom exception structs.</p>
</blockquote>
</aside>
<p>Well I have PTSD from C/C++, Java, Ruby, PHP and who knows what else so I started subconsciously avoiding exceptions in Elixir from the get go. This has not stopped me writing rock-solid apps that can literally only be brought down by a SIGKILL or the OOM reaper but using exceptions in my own code is another matter entirely – and I don’t use them.</p>
<p>But it’s likely that I am wrong to be so against them. No idea.</p>
<aside class="quote no-group" data-username="gregvaughn" data-post="19" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>Understanding that there are tradeoffs in any specific circumstance is what I consider pragmatic.</p>
</blockquote>
</aside>
<p>True, agreed. At the same time both you and me have decades of programming experience under our belts so there’s also the extra context that some practices almost always end up costing more than they benefit you so you learn to avoid them most of time. That’s what I do.</p>
<aside class="quote no-group" data-username="gregvaughn" data-post="19" data-topic="65163">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/gregvaughn/48/954_2.png" class="avatar"> gregvaughn:</div>
<blockquote>
<p>I’d even argue that once an anti-pattern is identified, it doesn’t automatically mean not to do it. Sometimes it can be justified in a given situation.</p>
</blockquote>
</aside>
<p>Agreed x2, that’s why I was mostly against the now-official Elixir list of anti-patterns. A lot of novices just lack the experience and critical thinking to tell themselves the following:</p>
<p></p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/4/a/4a419f971ca1f9920e3ed66c6501065f60221e0c.jpeg" data-download-href="https://forum.elixirforum.com/uploads/default/4a419f971ca1f9920e3ed66c6501065f60221e0c" title="guidelines_not_rules_1" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/original/3X/4/a/4a419f971ca1f9920e3ed66c6501065f60221e0c.jpeg" alt="guidelines_not_rules_1" data-base62-sha1="aATVG48ioG13H4nFezMOaMGdtg0" width="300" height="199"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">guidelines_not_rules_1</span><span class="informations">400×266 37.5 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p>
<p>…and they become dogmatic themselves. Sad story but what can you do. Also off-topic.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="336056" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/is-this-a-violation-of-the-anti-pattern-complex-else-clauses-in-with/65163/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-336056" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="336056"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>