Skip to content

Commit 4756872

Browse files
committed
Merge branch 'feature/throw-errors-in-threadpool' into feature/multiple-keys-for-context
2 parents 8aa390a + dd6fe57 commit 4756872

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ bin/
1717

1818
*.prefs
1919

20+
# Eclipse
21+
.classpath
22+
.project
23+
*.swp
24+
2025
# IntelliJ / Idea
2126
*.idea
2227
log/

src/org/uu/nl/net2apl/core/deliberation/DeliberationRunnable.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public void run(){
5050
// If all deliberation steps are finished, then check whether
5151
// the agent is done, so it can be killed.
5252
if(this.agent.isDone()){
53-
agent.getShutdownPlans().forEach( plan -> { try { agent.executePlan(plan); } catch (PlanExecutionError ex) { /*TODO?*/ } } );
54-
this.platform.killAgent(this.agent.getAID());
53+
initiateShutdown(this.agent);
5554
} else {
5655
if(!this.agent.checkSleeping()){ // If the agents goes to sleep then it will be woken upon any external input (message, external trigger)
5756
reschedule();
@@ -62,13 +61,28 @@ public void run(){
6261
// killed and removed from the platform. All proxy's are
6362
// notified of the agent's death. The rest of the multi-
6463
// agent system will continue execution by default.
65-
this.platform.killAgent(this.agent.getAID());
66-
}
64+
Platform.getLogger().log(getClass(), exception);
65+
this.platform.killAgent(this.agent.getAID());
66+
}
6767
} else {
68-
agent.getShutdownPlans().forEach( plan -> { try { agent.executePlan(plan); } catch (PlanExecutionError ex) { /*TODO?*/ } } );
69-
this.platform.killAgent(this.agent.getAID());
68+
initiateShutdown(agent);
7069
}
71-
}
70+
}
71+
72+
/** Perform shutdown plans, and kill agent **/
73+
private void initiateShutdown(Agent agent) {
74+
agent.getShutdownPlans().forEach(
75+
plan -> {
76+
try {
77+
agent.executePlan(plan);
78+
} catch (PlanExecutionError ex) {
79+
Platform.getLogger().log(plan.getClass(), ex);
80+
/*TODO?*/
81+
}
82+
}
83+
);
84+
this.platform.killAgent(agent.getAID());
85+
}
7286

7387
/** Returns the id of the agent to which this runnable belongs. */
7488
public final AgentID getAgentID(){ return this.agent.getAID(); }

src/org/uu/nl/net2apl/core/logging/Loggable.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public void log(Class<?> c, Object message) {
3232
* @param ex The exception to log
3333
*/
3434
public void log(Class<?> c, Exception ex) {
35-
log(c, Level.SEVERE, ex.getMessage());
35+
String msg = ex.getMessage() == null ? "<No Message>" : ex.getMessage();
36+
log(c, Level.SEVERE, msg);
37+
if(ex.getStackTrace() != null) {
38+
for(StackTraceElement el : ex.getStackTrace()) {
39+
log(c, Level.SEVERE, "\t| " + el.toString());
40+
}
41+
}
3642
}
3743
}

0 commit comments

Comments
 (0)