Improve JS error loggin

This commit is contained in:
Paulo Gustavo Veiga 2022-02-12 09:15:18 -08:00
parent 609fdd7144
commit f35d145fb8
2 changed files with 6 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import com.wisemapping.filter.SupportedUserAgent;
import com.wisemapping.model.Collaboration; import com.wisemapping.model.Collaboration;
import com.wisemapping.model.Mindmap; import com.wisemapping.model.Mindmap;
import com.wisemapping.model.User; import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestLogItem;
import com.wisemapping.util.VelocityEngineUtils; import com.wisemapping.util.VelocityEngineUtils;
import com.wisemapping.util.VelocityEngineWrapper; import com.wisemapping.util.VelocityEngineWrapper;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
@ -163,10 +164,11 @@ final public class NotificationService {
this.velocityEngineWrapper = engine; this.velocityEngineWrapper = engine;
} }
public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable User user, @Nullable String jsErrorMsg, @NotNull HttpServletRequest request) { public void reportJavascriptException(@Nullable Mindmap mindmap, @Nullable User user, @NotNull RestLogItem errorItem, @NotNull HttpServletRequest request) {
final Map<String, String> model = new HashMap<>(); final Map<String, String> model = new HashMap<>();
model.put("errorMsg", jsErrorMsg); model.put("JS-MSG", errorItem.getJsErrorMsg());
model.put("JS-STACK", errorItem.getJsStack());
String mindmapXML = ""; String mindmapXML = "";
try { try {

View File

@ -133,8 +133,8 @@ public class AccountController extends BaseController {
public void logError(@RequestBody RestLogItem item, @NotNull HttpServletRequest request) { public void logError(@RequestBody RestLogItem item, @NotNull HttpServletRequest request) {
final Mindmap mindmap = mindmapService.findMindmapById(item.getMapId()); final Mindmap mindmap = mindmapService.findMindmapById(item.getMapId());
final User user = Utils.getUser(); final User user = Utils.getUser();
logger.error("Unexpected editor error - " + item.getJsErrorMsg());
notificationService.reportJavascriptException(mindmap, user, item.getJsErrorMsg() + "\n" + item.getJsStack(), request); notificationService.reportJavascriptException(mindmap, user, item, request);
} }
} }