How to rescue PG::NotNullViolation error in Ruby?
<p>I am getting <code>ActiveRecord::StatementInvalid: PG::NotNullViolation: ERROR</code>. Can anyone tell me how can I rescue the <code>PG::NotNullViolation</code>?</p>

<pre><code>begin
 x.save
rescue ActiveRecord::StatementInvalid
 puts "I get here"
end
</code></pre>

<p>But I want to rescue the exact error, do we have a way to do it?</p>