mardi 20 mars 2018

How to handle multiple exception raising statements elegantly in Scala

I am building a map structure by extracting 30-40 keys from unstructured text rows from messy csv data. i am extracting using regex on this messy data row , lot of time those values are not there so it generates exception,

I put these 40-50 statements in try , catch block and able to parse but issue is one exception is generated other statement will not be extracted so I started putting each comment inside a try catch block .

try{
statment: 1
statment:2
.
.
.statement 30
}

how to handle elegantly such scenario in scala to capture exception in each statement and continue building map structure without puting each statement inside separate try catch block.

try{
stat1
}

try{
stat2
}
....

Thanks

Aucun commentaire:

Enregistrer un commentaire