sub my_request { my($session_id, $data) = @_; eval { }; if($@) { if($@ ne primary_key_violation) { } # No else, since the primary_key_violation # just means that the data has been inserted # by another request } }