add meaningful error message on upload [fixes #773]
This commit is contained in:
parent
eae2e74152
commit
dca2fbcefc
6 changed files with 24 additions and 3 deletions
app/controllers
|
@ -8,5 +8,11 @@ class UploadsController < ApplicationController
|
|||
return render status: 415, json: failed_json unless file.content_type =~ /^image\/.+/
|
||||
upload = Upload.create_for(current_user.id, file, params[:topic_id])
|
||||
render_serialized(upload, UploadSerializer, root: false)
|
||||
rescue FastImage::ImageFetchFailure
|
||||
render status: 422, text: I18n.t("upload.image.fetch_failure")
|
||||
rescue FastImage::UnknownImageType
|
||||
render status: 422, text: I18n.t("upload.image.unknown_image_type")
|
||||
rescue FastImage::SizeNotFound
|
||||
render status: 422, text: I18n.t("upload.image.size_not_found")
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue