title: How to make a Try match in Scala that handles nulls?
body: <p>Im tying to make a cache client and when I get the object I have one of three scenarios, either a) I get the object, b) I get null or c) the cache throws out a error. To handle these Im trying to do something like this where in a hit I return something, but on both a miss and a error I return None, but run different functions.</p>
  <pre><code>Try { cache.get(key) } match {
        case Success(cacheValue) =&gt; {
          onHit()
          Some(cacheValue)
        }
        case Success(null) =&gt; {
          onMiss()
          None
        }
        case Failure(e) =&gt; {
          onError(e)
          None
        }
      }
  </code></pre>
  <p>But when I try to run it I get this error</p>
  <pre><code>[scalac-2.12]  found   : Null(null)
  [scalac-2.12]  required: Nothing
  [scalac-2.12]       case Success(null) =&gt; {
  </code></pre>
  <p>And I don't know what it means or how to fix it. Im not super familiar with scala but I thought that having a Success(null) should work? Any help or advise is appreciated.</p>