class JavaCvErrorCallback extends CvErrorCallback {

    static JavaCvErrorCallback instance;

    public JavaCvErrorCallback() {
        this(false);
    }
    public JavaCvErrorCallback(boolean showDialog) {
        this(showDialog, null);
    }
    public JavaCvErrorCallback(boolean showDialog, Component parent) {
        this(showDialog, parent, 0);
    }
    public JavaCvErrorCallback(boolean showDialog, Component parent, int rc) {
        instance = this;
        this.parent = parent;
        this.showDialog = showDialog;
        this.rc = rc;
    }

    private long lastErrorTime = 0;
    private Component parent;
    private boolean showDialog;
    private int rc;

    @Override public int call(int status, BytePointer func_name, BytePointer err_msg,
            BytePointer file_name, int line, Pointer userdata) {<FILL_FUNCTION_BODY>}
}

        final String title = "OpenCV Error";
        final String message = cvErrorStr(status) +
                " (" + err_msg.getString() + ")\nin function " +
                func_name.getString() + ", " + file_name.getString() + "(" + line + ")";
        Logger.getLogger(JavaCvErrorCallback.class.getName()).log(Level.SEVERE,
                title + ": " + message, new java.lang.Exception("Strack trace"));
        if (showDialog) {
            // Show no more than 1 dialog per second since we cannot stop OpenCV
            // from processing and throwing more errors. Maybe in the future
            // when JavaCPP allows us to throw Exceptions across...
            if (System.currentTimeMillis() - lastErrorTime > 1000) {
                EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent, message,
                                title, JOptionPane.ERROR_MESSAGE);
                    }
                });
            }
            lastErrorTime = System.currentTimeMillis();
        }
        return rc; // 0 = please don't terminate
    
<no_super_class>