Slim3 Controller‎ > ‎

Controller#run()

When you visit a url, Controller#run() is performed. It is a part of Conroller#runBare(). Conroller#runBare() is similar to TestCase#runBase() of JUnit. The source code of Conroller#runBare() is as follows:

runBare()

public Navigation runBare() throws Throwable {
    Navigation navigation = null;
    Throwable error = null;
    navigation = setUp();
    if (navigation != null) {
        return navigation;
    }
    try {
        navigation = run();
    } catch (Throwable t) {
        error = t;
    } finally {
        try {
            tearDown();
        } catch (Throwable t) {
            if (logger.isLoggable(Level.WARNING)) {
                logger.log(Level.WARNING, t.getMessage(), t);
            }
        }
    }
    if (error != null) {
        navigation = handleError(error);
    }
    return navigation;
}

Controller#setUp() is suitable for pre-processing. Controller#tearDown() is suitable for post-processing. Controller#handleError() is suitable for exception-processing.

Next...

Continue to URL mapping.


Comments