X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2Frequest%2FNodeRequestUtils.java;h=ed0c54c968b8043e8fc7383655f8b9cf268a6236;hb=fc2c84b45f73743c48cd525e85355362444d67a5;hp=2e67010eba24bf013d9da01c884b3f7d174409b3;hpb=f23dc81afe57e77d20706a9a94002ce4c72f670d;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java index 2e67010eb..ed0c54c96 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/NodeRequestUtils.java @@ -1,55 +1,55 @@ -package org.simantics.document.server.request; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.io.UnsupportedEncodingException; - -import org.simantics.db.layer0.exception.MissingVariableException; -import org.simantics.db.layer0.scl.SCLDatabaseException; -import org.simantics.document.server.DocumentException; -import org.simantics.scl.compiler.module.repository.ImportFailure; -import org.simantics.scl.compiler.module.repository.ImportFailureException; -import org.simantics.scl.compiler.top.NotFoundException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class NodeRequestUtils { - private static final Logger LOGGER = LoggerFactory.getLogger(NodeRequestUtils.class); - - public static String formatErrorMessage(String name, Throwable t) { - - while(t.getCause() != null) - t = t.getCause(); - - if (t instanceof DocumentException) { - return t.getMessage(); - } else if (t instanceof MissingVariableException) { - return "Evaluation of property '" + name + "' failed\n" + - t.getMessage(); - } else if (t instanceof SCLDatabaseException) { - return t.getMessage(); - } else if (t instanceof NotFoundException) { - return t.getMessage(); - } else if (t instanceof ImportFailureException) { - ImportFailureException e = (ImportFailureException)t; - StringBuilder sb = new StringBuilder(); - sb.append("The following SCL modules failed to compile:\n"); - for(ImportFailure f : e.failures) - sb.append(" " + f.moduleName + "\n"); - return sb.toString(); - } else { - LOGGER.error("Node request error:", t); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - t.printStackTrace(ps); - try { - return baos.toString("UTF-8"); - } catch (UnsupportedEncodingException e) { - return baos.toString(); - } - - } - } - -} +package org.simantics.document.server.request; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; + +import org.simantics.db.layer0.exception.MissingVariableException; +import org.simantics.db.layer0.scl.SCLDatabaseException; +import org.simantics.document.server.DocumentException; +import org.simantics.scl.compiler.module.repository.ImportFailure; +import org.simantics.scl.compiler.module.repository.ImportFailureException; +import org.simantics.scl.compiler.top.NotFoundException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NodeRequestUtils { + private static final Logger LOGGER = LoggerFactory.getLogger(NodeRequestUtils.class); + + public static String formatErrorMessage(String name, Throwable t) { + + while(t.getCause() != null) + t = t.getCause(); + + if (t instanceof DocumentException) { + return t.getMessage(); + } else if (t instanceof MissingVariableException) { + return "Evaluation of property '" + name + "' failed\n" + + t.getMessage(); + } else if (t instanceof SCLDatabaseException) { + return t.getMessage(); + } else if (t instanceof NotFoundException) { + return t.getMessage(); + } else if (t instanceof ImportFailureException) { + ImportFailureException e = (ImportFailureException)t; + StringBuilder sb = new StringBuilder(); + sb.append("The following SCL modules failed to compile:\n"); + for(ImportFailure f : e.failures) + sb.append(" " + f.moduleName + "\n"); + return sb.toString(); + } else { + LOGGER.error("Node request error:", t); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintStream ps = new PrintStream(baos); + t.printStackTrace(ps); + try { + return baos.toString("UTF-8"); + } catch (UnsupportedEncodingException e) { + return baos.toString(); + } + + } + } + +}