File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
src/main/scala/com/codacy/plugins/utils Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,14 @@ package com.codacy.plugins.utils
3
3
import com .codacy .plugins .api .PatternDescription
4
4
import com .codacy .plugins .api .results .{Pattern , Tool }
5
5
import com .codacy .plugins .runners .IDocker
6
- import play .api .libs .json .{Format , Json }
6
+ import play .api .libs .json .{Format , JsResultException , Json }
7
+ import wvlet .log .LogSupport
7
8
8
9
import java .io .File
9
10
import java .nio .file .{Path , Paths }
10
11
import scala .util .Try
11
12
12
- trait IDockerHelper {
13
+ trait IDockerHelper extends LogSupport {
13
14
def loadDescription (docker : IDocker ): Option [Set [PatternDescription ]]
14
15
def loadPatterns (docker : IDocker ): Option [Tool .Specification ]
15
16
def loadVersion (docker : IDocker ): Option [String ]
@@ -68,7 +69,14 @@ abstract class DockerHelper extends IDockerHelper {
68
69
69
70
private def readJsonDoc [T ](docker : IDocker , path : Path )(implicit docFmt : Format [T ]): Option [T ] = {
70
71
val json = readRaw(docker, path).map(Json .parse)
71
- json.flatMap(_.asOpt[T ])
72
+ json.flatMap(jsValue => {
73
+ Try (jsValue.as[T ])
74
+ .recover({
75
+ case e : JsResultException =>
76
+ e.errors.foreach(m => error(s " Error parsing JSON: $m" ))
77
+ throw e
78
+ })
79
+ .toOption
80
+ })
72
81
}
73
-
74
82
}
You can’t perform that action at this time.
0 commit comments