Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Commit

Permalink
onerror und always angepasst
Browse files Browse the repository at this point in the history
  • Loading branch information
mrothenbuecher committed Apr 18, 2016
1 parent de951dc commit ee857be
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions src/de/finetech/groovy/AbasBaseScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void aktion(String cmd) {
* Methode wird immer ausgeführt nach Ende des Scriptes
*
*/
public void always(){}
public Object always(){return null;}

/**
* Definition genau einer NutzerVariablen
Expand Down Expand Up @@ -320,8 +320,12 @@ public void blocksatz(String cmd) {
FO.blocksatz(cmd);
}

public void box(String cmd) {
FO.box(cmd);
}

public void box(String title, String content) {
FO.box(title, content);
FO.box(title, content.split("\n"));
}

public void bringe() {
Expand All @@ -332,6 +336,10 @@ public void bringe(String cmd) {
EKS.bringe(cmd);
}

public void browser(String cmd){
FO.browser(cmd);
}

public void color(String cmd) {
this.farbe(cmd);
}
Expand Down Expand Up @@ -997,7 +1005,18 @@ public void occupy(String cmd) {
/**
* Methode wird beim Auftretten einer unbehandelten Ausnahme ausgeführt
*/
public void onerror(){}
public Object onerror(Object ex){
if(ex instanceof Exception){
Exception e = (Exception) ex;
e.printStackTrace();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
println("Unbehandelte Ausnahme: \n"+
sw.toString());
}
return null;
}

public void output(String cmd) {
ausgabe(cmd);
Expand Down Expand Up @@ -1041,6 +1060,7 @@ public void println(Object cmd) {

public void println(String cmd) {
cmd = cmd.replaceAll("\"", "'DBLQUOTE'");
// String kürzen
if (cmd.length() > 2999)
FO.println(cmd.substring(0, 2999));
else
Expand Down Expand Up @@ -1116,14 +1136,7 @@ public Object run(){
try{
o = runCode();
}catch(Exception e){
onerror();
e.printStackTrace();
FO.box("Fehler", e.getMessage());
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
FO.box("Unbehandelte Ausnahme in " + arg1[1],
sw.toString());
onerror(e);
}
finally{
always();
Expand Down

0 comments on commit ee857be

Please sign in to comment.