use of com.axelor.exception.db.TraceBack in project axelor-open-suite by axelor.
the class TraceBackService method _create.
/**
* Créer un log des exceptions en tant qu'anomalie.
*
* @param e L'exception générée.
* @param categorySelect <code>0 = Champ manquant</code> <code>1 = Clef non unique</code> <code>
* 2 = Aucune valeur retournée</code> <code>3 = Problème de configuration</code>
*/
private static TraceBack _create(Throwable e, String origin, int typeSelect, int categorySelect, long batchId) {
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
TraceBack traceBack = new TraceBack();
traceBack.setException(e.toString());
traceBack.setDate(ZonedDateTime.now());
traceBack.setError(e.getStackTrace() != null && e.getStackTrace().length > 0 ? e.getStackTrace()[0].toString() : e.getMessage());
traceBack.setOrigin(origin);
traceBack.setTypeSelect(typeSelect);
traceBack.setCategorySelect(categorySelect);
traceBack.setBatchId(batchId);
if (AuthUtils.getSubject() != null) {
traceBack.setInternalUser(AuthUtils.getUser());
}
if (e.getCause() != null) {
traceBack.setCause(e.getCause().toString());
}
if (e.getMessage() != null) {
traceBack.setMessage(e.getMessage());
}
traceBack.setTrace(sw.toString());
Beans.get(TraceBackRepository.class).persist(traceBack);
return traceBack;
}
use of com.axelor.exception.db.TraceBack in project axelor-open-suite by axelor.
the class TraceBackService method _create.
private static TraceBack _create(AxelorException e, String origin, long batchId) {
TraceBack traceBack = _create(e, origin, TYPE_FUNCTIONAL, e.getCategory(), batchId);
if (e.getRefClass() != null) {
traceBack.setRef(e.getRefClass().getName());
traceBack.setRefId(e.getRefId());
}
return traceBack;
}
use of com.axelor.exception.db.TraceBack in project axelor-open-suite by axelor.
the class TraceBackController method showReference.
/**
* Show reference view.
*
* @param request
* @param response
*/
public void showReference(ActionRequest request, ActionResponse response) {
TraceBack traceBack = request.getContext().asType(TraceBack.class);
if (Strings.isNullOrEmpty(traceBack.getRef())) {
return;
}
Class<?> modelClass = JPA.model(traceBack.getRef());
final Inflector inflector = Inflector.getInstance();
String viewName = inflector.dasherize(modelClass.getSimpleName());
LOG.debug("Showing anomaly reference ::: {}", viewName);
ActionViewBuilder actionViewBuilder = ActionView.define(I18n.get("Reference"));
actionViewBuilder.model(traceBack.getRef());
if (traceBack.getRefId() != null) {
actionViewBuilder.context("_showRecord", traceBack.getRefId());
} else {
actionViewBuilder.add("grid", String.format("%s-grid", viewName));
}
actionViewBuilder.add("form", String.format("%s-form", viewName));
response.setView(actionViewBuilder.map());
}
Aggregations