Search in sources :

Example 1 with RoutingException

use of io.micronaut.web.router.exceptions.RoutingException in project micronaut-core by micronaut-projects.

the class DefaultRouteBuilder method buildRoute.

/**
 * Build a route.
 *
 * @param httpMethod The HTTP method
 * @param uri The URI
 * @param type The type
 * @param method The method
 * @param parameterTypes Parameters
 *
 * @return an {@link UriRoute}
 */
protected UriRoute buildRoute(HttpMethod httpMethod, String uri, Class<?> type, String method, Class... parameterTypes) {
    Optional<? extends MethodExecutionHandle<?, Object>> executionHandle = executionHandleLocator.findExecutionHandle(type, method, parameterTypes);
    MethodExecutionHandle<?, Object> executableHandle = executionHandle.orElseThrow(() -> new RoutingException("No such route: " + type.getName() + "." + method));
    return buildRoute(httpMethod, uri, executableHandle);
}
Also used : RoutingException(io.micronaut.web.router.exceptions.RoutingException)

Example 2 with RoutingException

use of io.micronaut.web.router.exceptions.RoutingException in project micronaut-core by micronaut-projects.

the class DefaultRouteBuilder method error.

@Override
public ErrorRoute error(Class originatingClass, Class<? extends Throwable> error, Class type, String method, Class[] parameterTypes) {
    Optional<MethodExecutionHandle<?, Object>> executionHandle = executionHandleLocator.findExecutionHandle(type, method, parameterTypes);
    MethodExecutionHandle<?, Object> executableHandle = executionHandle.orElseThrow(() -> new RoutingException("No such route: " + type.getName() + "." + method));
    DefaultErrorRoute errorRoute = new DefaultErrorRoute(originatingClass, error, executableHandle, conversionService);
    this.errorRoutes.add(errorRoute);
    return errorRoute;
}
Also used : RoutingException(io.micronaut.web.router.exceptions.RoutingException) MethodExecutionHandle(io.micronaut.inject.MethodExecutionHandle)

Example 3 with RoutingException

use of io.micronaut.web.router.exceptions.RoutingException in project micronaut-core by micronaut-projects.

the class DefaultRouteBuilder method status.

@Override
public StatusRoute status(Class originatingClass, HttpStatus status, Class type, String method, Class[] parameterTypes) {
    Optional<MethodExecutionHandle<?, Object>> executionHandle = executionHandleLocator.findExecutionHandle(type, method, parameterTypes);
    MethodExecutionHandle<?, Object> executableHandle = executionHandle.orElseThrow(() -> new RoutingException("No such route: " + type.getName() + "." + method));
    DefaultStatusRoute statusRoute = new DefaultStatusRoute(originatingClass, status, executableHandle, conversionService);
    this.statusRoutes.add(statusRoute);
    return statusRoute;
}
Also used : RoutingException(io.micronaut.web.router.exceptions.RoutingException) MethodExecutionHandle(io.micronaut.inject.MethodExecutionHandle)

Aggregations

RoutingException (io.micronaut.web.router.exceptions.RoutingException)3 MethodExecutionHandle (io.micronaut.inject.MethodExecutionHandle)2