All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.lingkang.finalsecurity.solonplugin.config.DefaultFinalExceptionHandler Maven / Gradle / Ivy

There is a newer version: 3.1.0
Show newest version
package top.lingkang.finalsecurity.solonplugin.config;

import org.noear.solon.core.handle.Context;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.lingkang.finalsecurity.common.base.FinalExceptionHandler;

/**
 * @author lingkang
 * Created by 2022/10/28
 * @since 3.0.0
 */
public class DefaultFinalExceptionHandler implements FinalExceptionHandler {
    private static final Logger log = LoggerFactory.getLogger(DefaultFinalExceptionHandler.class);

    /**
     * 需要注意, request、response 在 solon 下均为 org.noear.solon.core.handle.Context
     *
     * @param e
     * @param request  org.noear.solon.core.handle.Context
     * @param response org.noear.solon.core.handle.Context
     */
    @Override
    public void permissionException(Throwable e, Object request, Object response) {
        Context context = (Context) response;
        log.warn("URL=" + context.path() + "  " + e.getMessage());
        context.status(403);
        context.output(e.getMessage());
    }

    /**
     * 需要注意, request、response 在 solon 下均为 org.noear.solon.core.handle.Context
     *
     * @param e
     * @param request  org.noear.solon.core.handle.Context
     * @param response org.noear.solon.core.handle.Context
     */
    @Override
    public void notLoginException(Throwable e, Object request, Object response) {
        Context context = (Context) response;
        log.warn("URL=" + context.path() + "  " + e.getMessage());
        context.status(403);
        context.output(e.getMessage());
    }

    /**
     * 需要注意, request、response 在 solon 下均为 org.noear.solon.core.handle.Context
     *
     * @param e
     * @param request  org.noear.solon.core.handle.Context
     * @param response org.noear.solon.core.handle.Context
     */
    @Override
    public void exception(Throwable e, Object request, Object response) {
        Context context = (Context) response;
        log.warn("URL=" + context.path() + "  " + e.getMessage());
        context.status(200);
        context.output(e.getMessage());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy