001package react4j.annotations; 002 003import akasha.core.JsError; 004import java.lang.annotation.Documented; 005import java.lang.annotation.ElementType; 006import java.lang.annotation.Target; 007import react4j.ReactErrorInfo; 008 009/** 010 * Identifies the method that is called when a child view generates an error during rendering. 011 * The method works like a catch block, but for views. If this method generates an error, then this 012 * error will propagate to the closest OnError annotated method above it. 013 * 014 * <p>The method can have up to two optional parameters. One is of type {@link JsError} and indicates 015 * the error that was thrown. The other parameter is of type {@link ReactErrorInfo} and it contains 016 * information about the view stack when the error was thrown.</p> 017 * 018 * <p>The method must also conform to the following constraints:</p> 019 * <ul> 020 * <li>Must not be annotated with any other react4j annotation</li> 021 * <li>Must not return a value</li> 022 * <li>Must not be private</li> 023 * <li>Must not be public</li> 024 * <li>Must not be static</li> 025 * <li>Must not be abstract</li> 026 * <li>Must not throw exceptions</li> 027 * <li>Must be accessible from the same package as the class annotated by {@link View}</li> 028 * <li> 029 * Should not be public as not expected to be invoked outside the view. A warning will be generated but can 030 * be suppressed by the {@link SuppressWarnings} or {@link SuppressReact4jWarnings} annotations with a key 031 * "React4j:PublicMethod". This warning is also suppressed by the annotation processor if it is implementing 032 * an interface method. 033 * </li> 034 * <li> 035 * Should not be protected if in the class annotated with the {@link View} annotation as the method is not 036 * expected to be invoked outside the view. A warning will be generated but can be suppressed by the 037 * {@link SuppressWarnings} or {@link SuppressReact4jWarnings} annotations with a key "React4j:ProtectedMethod". 038 * </li> 039 * </ul> 040 */ 041@Documented 042@Target( ElementType.METHOD ) 043public @interface OnError 044{ 045}