Search in sources :

Example 1 with ValueString

use of org.pentaho.di.compatibility.ValueString in project pentaho-kettle by pentaho.

the class DatabaseLogExceptionFactory method getExceptionStrategy.

/**
 * <p>
 * Returns throw exception strategy depends on defined behavior. Default is suppress exception.
 * </p>
 * <p/>
 * <p>
 * This behavior can be overridden with 'kettle.properties' key-value using 'Edit Kettle.properties file' in Spoon or
 * other.
 * </p>
 * <p/>
 * <p>
 * Following this strategy - <code>System.getProperty(String key)</code> call will be used to check if key-value pair
 * is defined. If key-value pair is not defined or value is set to FALSE/N, exception will be checked and suppressable strategy
 * with short message can be chosen, otherwise throwable behavior will be used
 * </p>
 *
 * @param table
 *     logging table that participated in exception. Must be instance of {@link LogTableCoreInterface}, otherwise
 *     default suppress exception behavior will be used.
 * @param e
 *     if key-value pair is not defined or value is set to FALSE/N, e will be checked and suppressable strategy
 *     with short message can be chosen.
 * @return
 * @see {@link org.pentaho.di.core.Const#KETTLE_VARIABLES_FILE}
 */
public static LogExceptionBehaviourInterface getExceptionStrategy(LogTableCoreInterface table, Exception e) {
    DatabaseInterfaceExtended databaseInterface = extractDatabase(table);
    LogExceptionBehaviourInterface suppressableResult = suppressable;
    if (databaseInterface != null && !databaseInterface.fullExceptionLog(e)) {
        suppressableResult = suppressableWithShortMessage;
    }
    String val = System.getProperty(KETTLE_GLOBAL_PROP_NAME);
    // with a small penalty for backward compatibility
    if (val == null) {
        // same as before
        return suppressableResult;
    }
    ValueString sVal = new ValueString(val);
    return sVal.getBoolean() ? throwable : suppressableResult;
}
Also used : DatabaseInterfaceExtended(org.pentaho.di.core.database.DatabaseInterfaceExtended) ValueString(org.pentaho.di.compatibility.ValueString) ValueString(org.pentaho.di.compatibility.ValueString)

Aggregations

ValueString (org.pentaho.di.compatibility.ValueString)1 DatabaseInterfaceExtended (org.pentaho.di.core.database.DatabaseInterfaceExtended)1