I'm using a third party library that returns Exception information in the form of a String (not an Exception object). I want to extract certain parts of the String stack trace to show the user in a GUI.
Two examples:
com.sdf.configure.model.change.InvalidChangeException: transformed change validation failed
at com.sdf.configure.model.change.SimpleConfigChanger.performChange(SimpleConfigChanger.java:129)
at com.sdf.portal.service.QosPolicyServiceImpl.applyPolicySnapshot(QosPolicyServiceImpl.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.referentia.commons.distributed.remoting.jms.JmsServiceExporter$1$1.run(JmsServiceExporter.java:189)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.sdf.configure.model.change.InvalidChangeException: can't add input service policy: policy has queueing
at com.sdf.configure.model.validate.RuleBasedValidator$RuleBasedChangeValidator.checkValidChange(RuleBasedValidator.java:5188)
at com.sdf.configure.model.validate.AbstractContextChangeValidator.checkValidChange(AbstractContextChangeValidator.java:304)
at com.sdf.configure.model.validate.AbstractContextChangeValidator.checkValidChange(AbstractContextChangeValidator.java:140)
at com.sdf.configure.model.validate.RuleBasedValidator.checkValidChange(RuleBasedValidator.java:1039)
at com.sdf.configure.model.change.SimpleConfigChanger.performChange(SimpleConfigChanger.java:126)
... 12 more
I want to extract the text: can't add input service policy: policy has queueing
com.sdf.configure.model.change.InvalidChangeException: transformed change validation failed
at com.sdf.configure.model.change.SimpleConfigChanger.performChange(SimpleConfigChanger.java:129)
at com.sdf.portal.service.QosPolicyServiceImpl.applyPolicySnapshot(QosPolicyServiceImpl.java:99)
at sun.reflect.GeneratedMethodAccessor139.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sdf.commons.distributed.remoting.jms.JmsServiceExporter$1$1.run(JmsServiceExporter.java:189)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.sdf.configure.model.change.InvalidChangeException: compound change component validation failed
at com.sdf.configure.model.validate.AbstractContextChangeValidator.checkValidChange(AbstractContextChangeValidator.java:1309)
at com.sdf.configure.model.validate.AbstractContextChangeValidator.checkValidChange(AbstractContextChangeValidator.java:361)
at com.sdf.configure.model.validate.AbstractContextChangeValidator.checkValidChange(AbstractContextChangeValidator.java:140)
at com.sdf.configure.model.validate.RuleBasedValidator.checkValidChange(RuleBasedValidator.java:1039)
at com.sdf.configure.model.change.SimpleConfigChanger.performChange(SimpleConfigChanger.java:126)
... 11 more
Caused by: com.sdf.configure.model.change.InvalidChangeException: can't add input service policy: policy has shaping
at com.sdf.configure.model.validate.RuleBasedValidator$RuleBasedChangeValidator.checkValidChange(RuleBasedValidator.java:5180)
at com.sdf.configure.model.validate.AbstractContextChangeValidator.checkValidChange(AbstractContextChangeValidator.java:304)
at com.sdf.configure.model.validate.AbstractContextChangeValidator.checkValidChange(AbstractContextChangeValidator.java:1306)
... 15 more
I want to extract the text:
compound change component validation failed
can't add input service policy: policy has shaping
Any elegant way to do this? The only way to find the parts I want to extract seems to be that the pieces I want to extract are always preceded by:
Caused by: com.sdf.configure.model.change.InvalidChangeException: