package kalang.lang;

import kalang.annotation.Nullable;

/**
 *
 * @author Kason Yang
 */
public abstract class Script {

    public final static int SUCCESS = 0;

    private String[] arguments = new String[0];

    protected abstract void execute();

    public int run() {
        execute();
        return SUCCESS;
    }

    public int run(@Nullable String[] arguments) {
        if (arguments != null) {
            this.arguments = arguments;
        }
        return run();
    }
    
    protected String[] arguments(){
        return this.arguments;
    }

}

package kalang.lang;

import kalang.annotation.Nullable;

/**
 *
 * @author Kason Yang
 */
public abstract class Script {

    public final static int SUCCESS = 0;

    private String[] arguments = new String[0];

    protected abstract void execute() throws Throwable;

    public int run() throws Throwable {
        try{
            execute();
        }catch(Throwable e) {
            handleException(e);
        }
        return SUCCESS;
    }

    public int run(@Nullable String[] arguments) throws Throwable {
        if (arguments != null) {
            this.arguments = arguments;
        }
        return run();
    }
    
    protected String[] arguments(){
        return this.arguments;
    }
    
    protected void handleException(Throwable e) throws Throwable{
        throw e;
    }

}

add handleException