Skip to content

Commit eb31a37

Browse files
authored
[RORDEV-1471] Better ror-tools exception message (#1112)
1 parent d57b87c commit eb31a37

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
publishedPluginVersion=1.64.1
2-
pluginVersion=1.64.1
2+
pluginVersion=1.65.0-pre1
33
pluginName=readonlyrest
44

55
org.gradle.jvmargs=-Xmx6144m

ror-tools-core/src/main/scala/tech/beshu/ror/tools/core/patches/internal/filePatchers/JarManifestModifier.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ object JarManifestModifier {
3636
manifest.getMainAttributes.putValue(patchedByRorVersionPropertyName, rorVersion)
3737
Using(new JarOutputStream(tempJarFile.newOutputStream.buffered, manifest)) { jarOutput =>
3838
copyJarContentExceptManifestFile(jarFile, jarOutput)
39-
}.getOrElse(throw new IllegalStateException(s"Could not copy content of jar file ${file.name}"))
39+
}.fold(
40+
ex => throw IllegalStateException(s"Could not copy content of jar file ${file.name} because of [${ex.getMessage}]", ex),
41+
(_: Unit) => ()
42+
)
4043
tempJarFile.moveTo(file)(File.CopyOptions(overwrite = true))
41-
}.getOrElse(throw new IllegalStateException(s"Could not add ROR version to jar file ${file.name}"))
44+
}.fold(
45+
ex => throw IllegalStateException(s"Could not add ROR version to jar file ${file.name} because of [${ex.getMessage}]", ex),
46+
(_: File) => ()
47+
)
4248
}
4349

4450
def findPatchedFiles(esDirectory: EsDirectory): List[PatchedJarFile] = {
@@ -58,7 +64,10 @@ object JarManifestModifier {
5864
val name = entry.getName
5965
if (!name.equalsIgnoreCase("META-INF/MANIFEST.MF")) {
6066
jarOutput.putNextEntry(entry)
61-
Using(originalJarFile.getInputStream(entry))(_.transferTo(jarOutput))
67+
Using(originalJarFile.getInputStream(entry))(_.transferTo(jarOutput)).fold(
68+
ex => throw IllegalStateException(s"Could not copy content of ${entry.getName} because of [${ex.getMessage}]", ex),
69+
(_: Long) => ()
70+
)
6271
jarOutput.closeEntry()
6372
}
6473
}

0 commit comments

Comments
 (0)