diff options
author | Vitaly Takmazov | 2024-09-09 19:46:47 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2024-09-09 20:22:19 +0300 |
commit | 291f4498320b2325093fb92cc9fbd9b4cb815782 (patch) | |
tree | 41bee7955b74e1c0460cacccdf27a1eb00d247ea /src/main/java/com/juick/www/controllers/Settings.java | |
parent | a2be40353c07ef3777e2a5ef250856dc9fd0a30f (diff) |
Handle post errors
Diffstat (limited to 'src/main/java/com/juick/www/controllers/Settings.java')
-rw-r--r-- | src/main/java/com/juick/www/controllers/Settings.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/main/java/com/juick/www/controllers/Settings.java b/src/main/java/com/juick/www/controllers/Settings.java index 8d66bd36..449275c3 100644 --- a/src/main/java/com/juick/www/controllers/Settings.java +++ b/src/main/java/com/juick/www/controllers/Settings.java @@ -150,14 +150,20 @@ public class Settings { visitor.setCountry(request.getParameter("country")); visitor.setUrl(request.getParameter("url")); visitor.setDescription(request.getParameter("descr")); - String avatarTmpPath = HttpUtils.receiveMultiPartFile(newAvatar, storageService.getTemporaryDirectory()).getHost(); - if (StringUtils.isNotEmpty(avatarTmpPath)) { - storageService.saveAvatar(avatarTmpPath, visitor); - } - if (userService.updateUserInfo(visitor)) { - result = String.format("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", visitor.getName()); + try { + String avatarTmpPath = HttpUtils + .receiveMultiPartFile(newAvatar, storageService.getTemporaryDirectory()).getHost(); + if (StringUtils.isNotEmpty(avatarTmpPath)) { + storageService.saveAvatar(avatarTmpPath, visitor); + } + if (userService.updateUserInfo(visitor)) { + result = String.format("<p>Your info is updated.</p><p><a href='/%s/'>Back to blog</a>.</p>", + visitor.getName()); + } + applicationEventPublisher.publishEvent(new UpdateUserEvent(this, visitor)); + } catch (Exception e) { + result = "<p>" + e.getMessage() + ". <a href=\"/settings\">Back</a>.</p>"; } - applicationEventPublisher.publishEvent(new UpdateUserEvent(this, visitor)); break; case "jid-del": // FIXME: stop using ugnich-csv in parameters |