You need to use the `SObject.addError` method. Note that you can only pass in records from the trigger context as a parameter value. I would recommend modifying your method to accept the trigger records. Best practice is to put the error message in a `Custom Label` so you can configure this user-facing copy quickly and easily. Something like:

    public static void validateNoActiveContacts(List<Account> records)
    {
        Set<Id> accountsWithActiveContact = new Map<Id>([
            SELECT Id FROM Account WHERE Id IN (
                SELECT AccountId FROM Contact
                WHERE Inactive = false
                AND AccountId IN :records 
            )
        ]).keySet();
        for (Account record : records)
        {
            if (accountsWithActiveContact.contains(record.Id))
                record.addError(Label.Active_Contact_Error);
        }
    }