- Add freemind import exception data on failure.

This commit is contained in:
Paulo Gustavo Veiga
2012-09-29 12:39:20 -03:00
parent dfe07e2da0
commit 295fbba387
4 changed files with 89 additions and 34 deletions

View File

@@ -19,6 +19,7 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.ClientException;
import com.wisemapping.exceptions.ImportUnexpectedException;
import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestErrors;
@@ -67,6 +68,16 @@ public class BaseController {
return ex.getMessage();
}
@ExceptionHandler(Exception.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ResponseBody
public String handleImportErrors(@NotNull ImportUnexpectedException ex, @NotNull HttpServletRequest request) {
final User user = Utils.getUser();
notificationService.reportJavaException(ex, user, new String(ex.getFreemindXml()), request);
return ex.getMessage();
}
@ExceptionHandler(ValidationException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public RestErrors handleValidationErrors(@NotNull ValidationException ex) {

View File

@@ -19,6 +19,7 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.ImportUnexpectedException;
import com.wisemapping.exceptions.WiseMappingException;
import com.wisemapping.importer.ImportFormat;
import com.wisemapping.importer.Importer;
@@ -401,6 +402,8 @@ public class MindmapController extends BaseController {
} catch (ImporterException e) {
// @Todo: This should be an illegal argument exception. Review the all the other cases.
throw buildValidationException("xml", "The selected file does not seems to be a valid Freemind or WiseMapping file. Contact support in case the problem persists.");
} catch (Throwable e) {
throw new ImportUnexpectedException(e, freemindXml);
}
// Save new map ...