捕获较低级别的类引发的消息

时间:2018-04-19 01:58:42

标签: scala

我的应用程序有四个级别:(1)我的应用程序,(2)pivot4j,(3)olap4j和(4)Mondrian

如果我在Scala中运行此代码:

try {
     renderer.render(model, new HtmlRenderCallback(sw)) 
}
catch {
  case ex: Exception => println(ex.getMessage)
}

应用程序打印pivot4j抛出的错误:

org.olap4j.OlapException: mondrian gave exception while parsing query

如果我没有发现错误,那么堆栈跟踪(粗体显示相关消息):

  

play.api.http.HttpErrorHandlerExceptions $$ anon $ 1:执行   异常[[PivotException:org.olap4j.OlapException:mondrian给了   解析查询时的异常]]   at play.api.http.HttpErrorHandlerExceptions $ .throwableToUsefulException(HttpErrorHandler.scala:293)           at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:220)           at play.api.GlobalSettings $ class.onError(GlobalSettings.scala:160)           at play.api.DefaultGlobal $ .onError(GlobalSettings.scala:188)           at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:100)           at play.core.server.netty.PlayRequestHandler $$ anonfun $ 2 $$ anonfun $ apply $ 1.applyOrElse(PlayRequestHandler.scala:100)           at play.core.server.netty.PlayRequestHandler $$ anonfun $ 2 $$ anonfun $ apply $ 1.applyOrElse(PlayRequestHandler.scala:99)           在scala.concurrent.Future $$ anonfun $ recoverWith $ 1.apply(Future.scala:346)           在scala.concurrent.Future $$ anonfun $ recoverWith $ 1.apply(Future.scala:345)           在scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36)引起   作者:org.pivot4j.PivotException:org.olap4j.OlapException:mondrian   在解析查询时给出了异常           在org.pivot4j.impl.PivotModelImpl.getCellSet(PivotModelImpl.java:598)           在org.pivot4j.ui.table.TableRenderer.render(TableRenderer.java:425)           在olap.process.RunOlap.doRunMdx(RunOlap.scala:91)           at olap.process.RunOlap $$ anonfun $ runMdx $ 1.apply(RunOlap.scala:53)           at olap.process.RunOlap $$ anonfun $ runMdx $ 1.apply(RunOlap.scala:51)           at login.Authentication $ LoggedAction $$ anonfun $ invokeBlock $ 1.apply(LoggedAction.scala:47)           at login.Authentication $ LoggedAction $$ anonfun $ invokeBlock $ 1.apply(LoggedAction.scala:42)           在scala.concurrent.Future $$ anonfun $ flatMap $ 1.apply(Future.scala:253)           在scala.concurrent.Future $$ anonfun $ flatMap $ 1.apply(Future.scala:251)           在scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36)引起   by:org.olap4j.OlapException:mondrian在解析时给出了异常   查询           at mondrian.olap4j.MondrianOlap4jConnection $ Helper.createException(MondrianOlap4jConnection.java:858)           在mondrian.olap4j.MondrianOlap4jStatement.parseQuery(MondrianOlap4jStatement.java:375)           在mondrian.olap4j.MondrianOlap4jStatement.executeOlapQuery(MondrianOlap4jStatement.java:346)           at org.pivot4j.impl.PivotModelImpl.executeMdx(PivotModelImpl.java:646)           在org.pivot4j.impl.PivotModelImpl.getCellSet(PivotModelImpl.java:596)           在org.pivot4j.ui.table.TableRenderer.render(TableRenderer.java:425)           在olap.process.RunOlap.doRunMdx(RunOlap.scala:91)           at olap.process.RunOlap $$ anonfun $ runMdx $ 1.apply(RunOlap.scala:53)           at olap.process.RunOlap $$ anonfun $ runMdx $ 1.apply(RunOlap.scala:51)           at login.Authentication $ LoggedAction $$ anonfun $ invokeBlock $ 1.apply(LoggedAction.scala:47)

     

引起:mondrian.olap.MondrianException:Mondrian错误:MDX对象' [测量]。[单位成本]'在多维数据集'销售'

中找不到

Mondrian是发起错误的那个,我需要得到抛出的消息:

 MDX object '[Measures].[Unit Cost]' not found in cube 'Sales'

我试过了:

try {
     renderer.render(model, new HtmlRenderCallback(sw)) 
}
catch {
  case ex: MondrianException => println(ex.getMessage)
}

但是没有抓住错误。

1 个答案:

答案 0 :(得分:0)

使用Apache Commons ExceptionUtils获取根异常。