Display error message if file type is invalid

Raise a custom exception type and rescue it in the controller,
returning JSON so the UI can display a sensible error message.