Source:
<code>protected ViewModel onValidSubmit(HttpServletRequest request, HttpServletResponse response, Form form) throws Exception { String password = form.getFieldValue("password"); Application application = (Application) request.getAttribute(Application.class.getName()); String sptoken = form.getFieldValue("sptoken"); if (isJsonPreferred(request, response)) { Map<String, Object> model = new HashMap<>(); try { Account account = application.resetPassword(sptoken, password); if (autoLogin) { final AuthenticationResult result = new TransientAuthenticationResult(account); this.authenticationResultSaver.set(request, response, result); model.put("account", accountModelFactory.toMap(account, Collections.EMPTY_LIST)); } else { response.setContentType(MediaType.APPLICATION_JSON_VALUE); return null; } } catch (Exception e) { model = errorModelFactory.toError(request, e).toMap(); response.setStatus(errorModelFactory.toError(request, e).getStatus()); } return new DefaultViewModel(View.STORMPATH_JSON_VIEW_NAME, model); } String next; try { Account account = application.resetPassword(sptoken, password); if (autoLogin) { final AuthenticationResult result = new TransientAuthenticationResult(account); this.authenticationResultSaver.set(request, response, result); next = this.loginNextUri; } else { <START> next = this.nextUri; <END> } } catch (ResourceException e) { if (e.getCode() == HttpStatus.SC_NOT_FOUND) { next = this.errorUri; } else { ErrorModel errorModel = errorModelFactory.toError(request, e); next = getUri() + "?sptoken=" + sptoken + "&error=" + URLEncoder.encode(errorModel.getMessage(), "UTF-8"); } } return new DefaultViewModel(next).setRedirect(true); }</code><technical_language>I catching Exception ResourceExcepton. If this catch properly written this means exception other a ResourceExcpetion thrown. If is case exception caught errors in invoking code</technical_language>

Target:
protected ViewModel onValidSubmit(HttpServletRequest request, HttpServletResponse response, Form form) throws Exception { String password = form.getFieldValue("password"); Application application = (Application) request.getAttribute(Application.class.getName()); String sptoken = form.getFieldValue("sptoken"); if (isJsonPreferred(request, response)) { Map<String, Object> model = new HashMap<>(); try { Account account = application.resetPassword(sptoken, password); if (autoLogin) { final AuthenticationResult result = new TransientAuthenticationResult(account); this.authenticationResultSaver.set(request, response, result); model.put("account", accountModelFactory.toMap(account, Collections.EMPTY_LIST)); } else { response.setContentType(MediaType.APPLICATION_JSON_VALUE); return null; } } catch (Exception e) { model = errorModelFactory.toError(request, e).toMap(); response.setStatus(errorModelFactory.toError(request, e).getStatus()); } return new DefaultViewModel(View.STORMPATH_JSON_VIEW_NAME, model); } String next; try { Account account = application.resetPassword(sptoken, password); if (autoLogin) { final AuthenticationResult result = new TransientAuthenticationResult(account); this.authenticationResultSaver.set(request, response, result); next = this.loginNextUri; } else { next = this.nextUri; } } catch (ResourceException e) { if (e.getCode() == HttpStatus.SC_NOT_FOUND) { next = this.errorUri; } else { ErrorModel errorModel = errorModelFactory.toError(request, e); next = getUri() + "?sptoken=" + sptoken + "&error=" + URLEncoder.encode(errorModel.getMessage(), "UTF-8"); } } catch (Exception e) { log.error("Caught exception: {}. Redirecting to: {}", e.getMessage(), errorUri, e); next = errorUri; } return new DefaultViewModel(next).setRedirect(true); }