JSON request, show error message

Hello
I am trying to show the errors that can occur by uploading a file (file
name, size).
I tried to modify this code cut-off but I could not.

else
   format.html { render action: "new" }
   format.json { render json: @upload.errors, status:
:unprocessable_entity }
end

I have following validations and I want json to write when an error
occured, so something like this:

else
   format.html { render action: "new" }
   format.json { render json: @upload.errors, status:
:unprocessable_entity, error:"Error!" }
end

(it doenst work) and I need a specification of an error, that is written
in a validation :message

my validations:

validates_uniqueness_of :upload_file_name, :message => "File with
this name is already in the database"

validates :upload_file_size, :inclusion => {:in
=>10.megabytes..20.megabytes}, :message =>"Too big or too small"

      def to_jq_upload
        {
          "name" => read_attribute(:upload_file_name),
          "size" => read_attribute(:upload_file_size),
          "url" => upload.url(:original),
          "delete_url" => upload_path(self),
          "delete_type" => "DELETE"
        }
      end

    end

Thanks in advanced