title: Catch PostgreSQL exception and change column value
body: <p>I have a column called <code>metadata</code> which has format <code>TEXT</code> but contains stuff that's usually a JSON. I want to select a certain value in it (<code>metadata :: JSON -&gt; 'register' -&gt;&gt; 'date'</code> for instance) but if the JSON is badly formatted or if the field doesn't exist I get an error. Can I make that column just return a <code>NULL</code> value when it would get an error instead?</p>