title: Custom exception hierarchy in Scala
body: <p>I've been reading up on how to properly handle (<code>Option</code>, <code>Try</code> and <code>Either</code>) and <a href="https://stackoverflow.com/questions/38243530/custom-exception-in-scala">define</a> exceptions in Scala.</p>
  
  <p>My question is: do exception hierarchies make sense in Scala? For example, we currently have a Scala project implementing something like:</p>
  
  <pre class="lang-scala prettyprint-override"><code>class ServiceException(msg: String) extends Exception(msg)
  class StorageServiceException(msg: String) extends ServiceException(msg)
  class StorageServiceNotAvailableException(msg: String)
    extends StorageServiceException(msg)
  </code></pre>
  
  <p>Is there an idiomatic way of defining such a hierarchy? Or maybe this concept is absorbed into something different altogether?</p>
  
  <p><strong>CONCLUSION FROM RESPONSES (see answer and comments below)</strong></p>
  
  <p>A hierarchy of exceptions makes sense if you want to recover from a non-leaf exception. Although, this doesn't prevent you from handling with <code>Option/Try/Either</code> mechanisms which is more idiomatic than the traditional <code>try/catch</code>.</p>