Package org.nutz.mvc.impl

Examples of org.nutz.mvc.impl.AdaptorErrorContext


        Object[] args = new Object[argTypes.length];

        if (args.length != injs.length)
            throw new IllegalArgumentException("args.length != injs.length , You get a bug, pls report it!!");

        AdaptorErrorContext errCtx = null;
        // 也许用户有自己的AdaptorErrorContext实现哦
        if (argTypes.length > 0) {
            if (AdaptorErrorContext.class.isAssignableFrom(argTypes[argTypes.length - 1]))
                errCtx = (AdaptorErrorContext) Mirror.me(argTypes[argTypes.length - 1])
                                                     .born(argTypes.length);
        }

        Object obj;
        try {
            obj = getReferObject(sc, req, resp, pathArgs);
        }
        catch (Throwable e) {
            if (errCtx != null) {
                if (log.isInfoEnabled())
                    log.info("Adapter Error catched , but I found AdaptorErrorContext param, so, set it to args, and continue");
                errCtx.setAdaptorError(e, this);
                args[args.length - 1] = errCtx;
                return args;
            }
            throw Lang.wrapThrow(e);
        }

        int len = Math.min(args.length, null == pathArgs ? 0 : pathArgs.length);
        for (int i = 0; i < args.length; i++) {
            Object value = null;
            if (i < len) { // 路径参数
                value = null == pathArgs ? null : pathArgs[i];
            } else { // 普通参数
                value = obj;
            }
            try {
                args[i] = injs[i].get(sc, req, resp, value);
            }
            catch (Throwable e) {
                if (errCtx != null)
                    errCtx.setError(i, e, method, value, injs[i]); // 先错误保存起来,全部转好了,再判断是否需要抛出
                else
                    throw Lang.wrapThrow(e);
            }
            if (args[i] == null && argTypes[i].isPrimitive()) {
                args[i] = Lang.getPrimitiveDefaultValue(argTypes[i]);
            }
        }

        // 看看是否有任何错误
        if (errCtx == null)
            return args;
        for (Throwable err : errCtx.getErrors()) {
            if (err == null)
                continue;
            int lastParam = argTypes.length - 1;
            if (AdaptorErrorContext.class.equals(argTypes[lastParam])) {
                if (log.isInfoEnabled())
View Full Code Here


        Object[] args = new Object[argTypes.length];

        if (args.length != injs.length)
            throw new IllegalArgumentException("args.length != injs.length , You get a bug, pls report it!!");

        AdaptorErrorContext errCtx = null;
        // 也许用户有自己的AdaptorErrorContext实现哦
        if (argTypes.length > 0) {
            if (AdaptorErrorContext.class.isAssignableFrom(argTypes[argTypes.length - 1]))
                errCtx = (AdaptorErrorContext) Mirror.me(argTypes[argTypes.length - 1])
                                                     .born(argTypes.length);
        }

        Object obj;
        try {
            obj = getReferObject(sc, req, resp, pathArgs);
        }
        catch (Throwable e) {
            if (errCtx != null) {
                if (log.isInfoEnabled())
                    log.info("Adapter Error catched , but I found AdaptorErrorContext param, so, set it to args, and continue", e);
                errCtx.setAdaptorError(e, this);
                args[args.length - 1] = errCtx;
                return args;
            }
            throw Lang.wrapThrow(e);
        }

        int len = Math.min(args.length, null == pathArgs ? 0 : pathArgs.length);
        for (int i = 0; i < args.length; i++) {
            Object value = null;
            if (i < len) { // 路径参数
                value = null == pathArgs ? null : pathArgs[i];
            } else { // 普通参数
                value = obj;
            }
            try {
                args[i] = injs[i].get(sc, req, resp, value);
            }
            catch (Throwable e) {
                if (errCtx != null) {
                  log.infof("Adapter Param Error(%s) index=%d", method, i, e);
                    errCtx.setError(i, e, method, value, injs[i]); // 先错误保存起来,全部转好了,再判断是否需要抛出
                } else
                    throw Lang.wrapThrow(e);
            }
            if (args[i] == null && argTypes[i].isPrimitive()) {
                args[i] = Lang.getPrimitiveDefaultValue(argTypes[i]);
            }
        }

        // 看看是否有任何错误
        if (errCtx == null)
            return args;
        for (Throwable err : errCtx.getErrors()) {
            if (err == null)
                continue;
            int lastParam = argTypes.length - 1;
            if (AdaptorErrorContext.class.isAssignableFrom(argTypes[lastParam])) {
                if (log.isInfoEnabled())
View Full Code Here

TOP

Related Classes of org.nutz.mvc.impl.AdaptorErrorContext

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.