Package br.com.caelum.vraptor

Examples of br.com.caelum.vraptor.InterceptionException


            validator.onErrorUse(nothing());
          } catch (ValidationException e) {
            log.debug("Some validation errors occured: {}", e.getErrors());
          }
        }
        throw new InterceptionException(
            "There are validation errors and you forgot to specify where to go. Please add in your method "
                + "something like:\n"
                + "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n"
                + "or any view that you like.\n"
                + "If you didn't add any validation error, it is possible that a conversion error had happened.");
      }
      this.methodInfo.setResult(result);
      methodExecutedEvent.fire(new MethodExecuted(method, methodInfo));
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (MethodExecutorException e) {
      throwIfNotValidationException(e,
          new ApplicationLogicException("your controller raised an exception", e.getCause()));
    } catch (Exception e) {
      throwIfNotValidationException(e, new InterceptionException(e));
    }
  }
View Full Code Here


        }
      }

      stack.next(method, resourceInstance);
    } catch (IOException e) {
      throw new InterceptionException(e);
    }

  }
View Full Code Here

            validator.onErrorUse(nothing());
          } catch (ValidationException e) {
            log.debug("Some validation errors occured: {}", e.getErrors());
          }
        }
        throw new InterceptionException(
            "There are validation errors and you forgot to specify where to go. Please add in your method "
                + "something like:\n"
                + "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n"
                + "or any view that you like.\n"
                + "If you didn't add any validation error, it is possible that a conversion error had happened.");
      }
      this.methodInfo.setResult(result);
      methodExecutedEvent.fire(new MethodExecuted(method, methodInfo));
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (ReflectionProviderException e) {
      throwIfNotValidationException(e, e.getCause());
    } catch (Exception e) {
      throwIfNotValidationException(e, e);
    }
View Full Code Here

      output.flush();
      output.close();

    } catch (IOException e) {
      throw new InterceptionException(e);
    }

  }
View Full Code Here

                        } else {
                            throw new IllegalArgumentException("Unsupported validation message type: " + msg.getClass().getName());
                        }
                    }
                } catch (GettingException e) {
                    throw new InterceptionException(
                            "Unable to validate objects due to an exception during validation.", e);
                }
            }
        }
        stack.next(method, resourceInstance);
View Full Code Here

        for (int i = 0; i < names.length; i++) {
            if (names[i].equals(param) || names[i].equals(Info.capitalize(param))) {
                return values[i];
            }
        }
        throw new InterceptionException("Unable to find param for hibernate validator: '" + path + "'");
    }
View Full Code Here

      throws InterceptionException {
    boolean accepts;
    try {
      accepts = getAcceptor().accepts(method);
    } catch (NullPointerException e) {
      throw new InterceptionException("StaticInterceptors should not use constructor parameters inside the accepts method", e);
    }
    if (accepts) {
      Interceptor interceptor = container.instanceFor(type);
      if (interceptor == null) {
        throw new InterceptionException("Unable to instantiate interceptor for " + type.getName()
            + ": the container returned null.");
      }
      logger.debug("Invoking interceptor {}", interceptor.getClass().getSimpleName());
      interceptor.intercept(stack, method, resourceInstance);
    } else {
View Full Code Here

        Constructor<?> constructor = type.getDeclaredConstructors()[0];
        int argsLength = constructor.getParameterTypes().length;
        acceptor = type.cast(new Mirror().on(type).invoke().constructor(constructor).withArgs(new Object[argsLength]));
      } catch (MirrorException e) {
        if (e.getCause() instanceof NullPointerException) {
          throw new InterceptionException("StaticInterceptors should not use constructor parameters inside the constructor", e);
        } else {
          throw new InterceptionException(e);
        }
      }
    }
    return acceptor;
  }
View Full Code Here

                validationParameters[0] = newErrors;
                System.arraycopy(parameters, 0, validationParameters, 1, parameters.length);
                try {
                    validationMethod.invoke(resourceInstance, validationParameters);
                } catch (IllegalArgumentException e) {
                    throw new InterceptionException("Unable to validate.", e);
                } catch (IllegalAccessException e) {
                    throw new InterceptionException("Unable to validate.", e);
                } catch (InvocationTargetException e) {
                    throw new InterceptionException("Unable to validate.", e.getCause());
                }
                for (Message msg : convertionErrors) {
                    errors.add(new FixedMessage(msg.getCategory(), msg.getMessage(), msg.getCategory()));
                }
                for (org.vraptor.i18n.ValidationMessage msg : newErrors) {
View Full Code Here

      log.debug("Invoking {}", Stringnifier.simpleNameFor(reflectionMethod));
      Object result = reflectionMethod.invoke(resourceInstance, parameters);

      if (validator.hasErrors()) { // method should have thrown
        // ValidationError
        throw new InterceptionException(
            "There are validation errors and you forgot to specify where to go. Please add in your method "
                + "something like:\n"
                + "validator.onErrorUse(page()).of(AnyController.class).anyMethod();\n"
                + "or any view that you like.\n"
                + "If you didn't add any validation error, it is possible that a conversion error had happened.");
      }

      if (reflectionMethod.getReturnType().equals(Void.TYPE)) {
        // vraptor2 compatibility
        this.info.setResult("ok");
      } else {
        this.info.setResult(result);
      }
      stack.next(method, resourceInstance);
    } catch (IllegalArgumentException e) {
      throw new InterceptionException(e);
    } catch (IllegalAccessException e) {
      throw new InterceptionException(e);
    } catch (InvocationTargetException e) {
      Throwable cause = e.getCause();
      if (cause instanceof ValidationException) {
        // fine... already parsed
        log.trace("swallowing {}", cause);
      } else {
        throw new InterceptionException("exception raised, check root cause for details: " + cause, cause);
      }
    }
  }
View Full Code Here

TOP

Related Classes of br.com.caelum.vraptor.InterceptionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.