             counter++
             $('.import-counter').html counter
 
-        addAlarmError = (alarm) ->
+        addError = (element, templatePath) ->
             if $('.import-errors').html().length is 0
                 $('.import-errors').html """
                 <p>#{t 'import error occured for'}:</p>
                 """
 
             $('.import-errors').append(
-                require('./templates/import_alarm')(alarm.attributes)
-            )
-
-        addEventError = (event) ->
-            $('.import-errors').append(
-                require('./templates/import_event')(event.attributes)
+                require(templatePath)(element.attributes)
             )
 
         # Show loading spinner.

                error: ->
                    # When an element failed to import, an error message is
                    # displayed.
                    addEventError event
                    updateCounter()
                    callback()


                error: ->
                    # When an element failed to import, an error message is
                    # displayed.
                    addAlarmError alarm, './templates/import_alarm'
                    updateCounter()
                    callback()

