Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find source of scala.MatchError?

I have a parser program in Scala sending string to it and breaking the string and parse. I am getting the following error on that which I don't even know which part of the program is wrong:

 Exception in thread "main" scala.MatchError: xxxx/xml/test3D.xml (of class java.lang.String)

What are the possibilities that I need to check and what is the best way to solve these kind of errors?

like image 858
Rubbic Avatar asked Jul 16 '15 23:07

Rubbic


1 Answers

There is exact place where exception occurred and it is described by file name and line number in this file. For example, look at this stack trace:

Exception in thread "main" scala.MatchError: 7 (of class java.lang.Integer)
at stackoverflow.M$.delayedEndpoint$stackoverflow$M$1(Functions.scala:35)
at stackoverflow.M$delayedInit$body.apply(Functions.scala:30)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)

Here you can see that exception cause is on line 35 in Functions.scala file. The second line in a stack trace is the line where exception was thrown. Check this line!

MatchError occurs whenever an object doesn't match any pattern of a pattern matching expression.

like image 79
ka4eli Avatar answered Nov 08 '22 05:11

ka4eli