<commit_before>package com.prairie.eevernote.exception;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Shell;

import com.evernote.edam.error.EDAMUserException;
import com.evernote.thrift.transport.TTransportException;
import com.prairie.eevernote.Constants;
import com.prairie.eevernote.EEPlugin;
import com.prairie.eevernote.Messages;
import com.prairie.eevernote.client.EEClipper;
import com.prairie.eevernote.util.EclipseUtil;
import com.prairie.eevernote.util.LogUtil;

public class ThrowableHandler implements Constants {

    private static String OUT_OF_DATE_ERROR = EEPlugin.getName() + StringUtils.EMPTY + EEPlugin.getVersion() + Messages.getString(PLUGIN_RUNTIME_ADDFILETOEVERNOTE_OUTOFDATEMESSAGE);

    public static void openError(final Shell shell, final String message) {
        EclipseUtil.openErrorSync(shell, Messages.getString(PLUGIN_ERROR_OCCURRED), message);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e) {
        handleDesignTimeErr(shell, e, false, null);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e, final boolean fatal) {
        handleDesignTimeErr(shell, e, fatal, null);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e, final EEClipper clipper) {
        handleDesignTimeErr(shell, e, false, clipper);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e, final boolean fatal, final EEClipper clipper) {
        if (e instanceof EDAMUserException) {
            new EDAMUserExceptionHandler().handleDesingTime(shell, (EDAMUserException) e);
        } else if (e instanceof OutOfDateException) {
            openError(shell, OUT_OF_DATE_ERROR);
        } else if (e instanceof TTransportException) {
            if (clipper != null) {
                clipper.setInvalid();
            }
            openError(shell, ExceptionUtils.getRootCauseMessage(e) + (fatal ? StringUtils.EMPTY : Messages.getString(Constants.PLUGIN_THROWABLE_NOTFATAL_MESSAGE)));
        } else {
            openError(shell, ExceptionUtils.getRootCauseMessage(e) + (fatal ? StringUtils.EMPTY : Messages.getString(Constants.PLUGIN_THROWABLE_NOTFATAL_MESSAGE)));
        }
    }

    public static IStatus handleJobErr(final Throwable e) {
        return handleJobErr(e, null);
    }

    public static IStatus handleJobErr(final Throwable e, final EEClipper clipper) {
        if (e instanceof EDAMUserException) {
            return new EDAMUserExceptionHandler().handleRuntime((EDAMUserException) e);
        } else if (e instanceof OutOfDateException) {
            return LogUtil.error(OUT_OF_DATE_ERROR);
        } else if (e instanceof TTransportException) {
            if (clipper != null) {
                clipper.setInvalid();
            }
            return LogUtil.error(e);
        } else {
            return LogUtil.error(e);
        }
    }

    public static ExecutionException handleExecErr(final Throwable e) {
        return handleExecErr(e, null);
    }

    public static ExecutionException handleExecErr(final Throwable e, final EEClipper clipper) {
        if (e instanceof OutOfDateException) {
            return new ExecutionException(OUT_OF_DATE_ERROR);<commit_msg>lazy init static property<commit_after>package com.prairie.eevernote.exception;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Shell;

import com.evernote.edam.error.EDAMUserException;
import com.evernote.thrift.transport.TTransportException;
import com.prairie.eevernote.Constants;
import com.prairie.eevernote.EEPlugin;
import com.prairie.eevernote.Messages;
import com.prairie.eevernote.client.EEClipper;
import com.prairie.eevernote.util.EclipseUtil;
import com.prairie.eevernote.util.LogUtil;

public class ThrowableHandler implements Constants {

    public static void openError(final Shell shell, final String message) {
        EclipseUtil.openErrorSync(shell, Messages.getString(PLUGIN_ERROR_OCCURRED), message);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e) {
        handleDesignTimeErr(shell, e, false, null);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e, final boolean fatal) {
        handleDesignTimeErr(shell, e, fatal, null);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e, final EEClipper clipper) {
        handleDesignTimeErr(shell, e, false, clipper);
    }

    public static void handleDesignTimeErr(final Shell shell, final Throwable e, final boolean fatal, final EEClipper clipper) {
        if (e instanceof EDAMUserException) {
            new EDAMUserExceptionHandler().handleDesingTime(shell, (EDAMUserException) e);
        } else if (e instanceof OutOfDateException) {
            openError(shell, EEPlugin.getName() + StringUtils.EMPTY + EEPlugin.getVersion() + Messages.getString(PLUGIN_RUNTIME_ADDFILETOEVERNOTE_OUTOFDATEMESSAGE));
        } else if (e instanceof TTransportException) {
            if (clipper != null) {
                clipper.setInvalid();
            }
            openError(shell, ExceptionUtils.getRootCauseMessage(e) + (fatal ? StringUtils.EMPTY : Messages.getString(Constants.PLUGIN_THROWABLE_NOTFATAL_MESSAGE)));
        } else {
            openError(shell, ExceptionUtils.getRootCauseMessage(e) + (fatal ? StringUtils.EMPTY : Messages.getString(Constants.PLUGIN_THROWABLE_NOTFATAL_MESSAGE)));
        }
    }

    public static IStatus handleJobErr(final Throwable e) {
        return handleJobErr(e, null);
    }

    public static IStatus handleJobErr(final Throwable e, final EEClipper clipper) {
        if (e instanceof EDAMUserException) {
            return new EDAMUserExceptionHandler().handleRuntime((EDAMUserException) e);
        } else if (e instanceof OutOfDateException) {
            return LogUtil.error(EEPlugin.getName() + StringUtils.EMPTY + EEPlugin.getVersion() + Messages.getString(PLUGIN_RUNTIME_ADDFILETOEVERNOTE_OUTOFDATEMESSAGE));
        } else if (e instanceof TTransportException) {
            if (clipper != null) {
                clipper.setInvalid();
            }
            return LogUtil.error(e);
        } else {
            return LogUtil.error(e);
        }
    }

    public static ExecutionException handleExecErr(final Throwable e) {
        return handleExecErr(e, null);
    }

    public static ExecutionException handleExecErr(final Throwable e, final EEClipper clipper) {
        if (e instanceof OutOfDateException) {
            return new ExecutionException(EEPlugin.getName() + StringUtils.EMPTY + EEPlugin.getVersion() + Messages.getString(PLUGIN_RUNTIME_ADDFILETOEVERNOTE_OUTOFDATEMESSAGE));
{'fraction_non_alphanumeric': 0.08505812305075135, 'fraction_numerical': 0.0005670541536716756, 'mean_word_length': 3.644502962475313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7592919', 'n_tokens_mistral': 2041, 'n_tokens_neox': 2003, 'n_words': 443}