<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Error Handling on Prateek Sharma</title>
		<link>https://prateeksharma.me/tags/error-handling/</link>
		<description>Recent content in Error Handling on Prateek Sharma</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Fri, 28 Aug 2026 00:00:00 +0000</lastBuildDate>
		
			<atom:link href="https://prateeksharma.me/tags/error-handling/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>Give callers two error types, one extending the other</title>
				<link>https://prateeksharma.me/opinions/two-exceptions-not-one/</link>
				<pubDate>Fri, 28 Aug 2026 00:00:00 +0000</pubDate>
				<guid>https://prateeksharma.me/opinions/two-exceptions-not-one/</guid>
				<description>&lt;p&gt;In the &lt;a href=&#34;https://prateeksharma.me/projects/wazirx-connector-java/&#34;&gt;WazirX Java connector&lt;/a&gt;&#xA; I split errors&#xA;into two:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;code&gt;WazirxClientException&lt;/code&gt; — the caller made a mistake the caller can fix: a bad&#xA;&lt;code&gt;side&lt;/code&gt; value, a missing required field. Thrown before a request is even sent.&lt;/li&gt;&#xA;&lt;li&gt;&lt;code&gt;WazirxApiException&lt;/code&gt; — something went wrong once the request left the process:&#xA;a network failure, a non-2xx response.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;code&gt;WazirxClientException extends WazirxApiException&lt;/code&gt;. That one line is the whole&#xA;design. A caller who only cares &amp;ldquo;did this work?&amp;rdquo; catches the parent. A caller who&#xA;wants to retry network failures but fail fast on their own bad input catches both&#xA;separately. Nobody is forced into a giant &lt;code&gt;catch (Exception e)&lt;/code&gt; that swallows&#xA;bugs, and nobody has to &lt;code&gt;try/catch&lt;/code&gt; five specific types at every call site.&lt;/p&gt;</description>
			</item>
	</channel>
</rss>
