title: Decode a response from a catch in Dart
body: <p>I try to decode the response returned from a catch, here is what I tried :</p>
  
  <pre><code>try{
    ...
  } catch (err) {
      //JsonCodec codec = new JsonCodec(); // doesn't work
      //var decoded = codec.decode(err);
      ...
   }
  </code></pre>
  
  <blockquote>
    <p>Error: type '_Exception' is not a subtype of type 'String'</p>
  </blockquote>
  
  <p>print(err) :</p>
  
  <blockquote>
    <p>Exception: {
               "error": {
                   "code": "invalid_expiry_year"
               }
            }</p>
  </blockquote>
  
  <p>I would like to get the value of "code", I tried many things but it doesn't work, </p>
  
  <p>Any idea?</p>
  
  <pre><code> print(err.code);
  </code></pre>
  
  <p>then I get :</p>
  
  <p><a href="https://i.stack.imgur.com/YP2W1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YP2W1.png" alt="enter image description here"></a></p>