Skip to content

Commit

Permalink
eventbus增加错误日志输出
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangwenping committed Jun 1, 2017
1 parent 323ceb3 commit 7e154ff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
16 changes: 13 additions & 3 deletions src/main/java/com/snowcattle/game/executor/event/EventBus.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ public void handleEvent() {
if(event == null){
break;
}
handleSingleEvent(event);
try {
handleSingleEvent(event);
}catch (Exception e){
Loggers.gameExecutorError.error(e.toString(), e);
}

}
}

Expand All @@ -86,7 +91,12 @@ public int cycle(int maxSize) {
if(event == null){
break;
}
handleSingleEvent(event);
try {
handleSingleEvent(event);
}catch (Exception e){
Loggers.gameExecutorError.error(e.toString(), e);
}

i++;
if(i > maxSize){
break;
Expand All @@ -96,7 +106,7 @@ public int cycle(int maxSize) {
return i;
}

public void handleSingleEvent(IEvent event) {
public void handleSingleEvent(IEvent event) throws Exception{

if(Loggers.gameExecutorUtil.isDebugEnabled()) {
EventParam[] eventParams = event.getParams();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public interface IEventBus {
public void clearEventListener();
public void addEvent(IEvent event);
public void handleEvent();
public void handleSingleEvent(IEvent event);
public void handleSingleEvent(IEvent event) throws Exception;
public void clearEvent();
public void clear();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.snowcattle.game.executor.event.service;

import com.snowcattle.game.executor.common.utils.Loggers;
import com.snowcattle.game.executor.event.EventBus;
import com.snowcattle.game.executor.event.SingleEvent;
import com.snowcattle.game.thread.worker.AbstractWork;
Expand All @@ -20,6 +21,11 @@ public SingleEventWork(EventBus eventBus, SingleEvent singleEvent) {

@Override
public void run() {
eventBus.handleSingleEvent(singleEvent);
try {
eventBus.handleSingleEvent(singleEvent);
}catch (Exception e){
Loggers.gameExecutorError.error(e.toString(), e);
}

}
}

0 comments on commit 7e154ff

Please sign in to comment.