bool isViolation(ex, String code)

Whether it is PostgresqlException about the violation of the given code.

Source Link to Crossdart

bool isViolation(ex, String code)
=> ex is PostgresqlException && ex.serverMessage != null
    && ex.serverMessage.code == code;