OSDN Git Service

t#30328:create op import ...and pull
[pettanr/pettanr.git] / app / models / system_picture.rb
index cd4809b..631b3c5 100644 (file)
@@ -111,10 +111,11 @@ class SystemPicture < ActiveRecord::Base
     res = false
     SystemPicture.transaction do
       if res = self.save
-        if res = PictureIO.system_picture_io.put(imager.binary, self.filename)
-          res = true
-        else
-          self.errors.add :base, 'system picture io does not work'
+        begin
+          res = PictureIO.system_picture_io.put(imager.binary, self.filename)
+        rescue PictureIO::Error
+          res = false
+          self.errors.add :base, I18n.t('picture_io.error')
           raise ActiveRecord::Rollback
         end
       end