Skip to content

Commit c3f7c68

Browse files
committed
Move project path validation to core library
1 parent 488ba2b commit c3f7c68

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/main/kotlin/com/tomwyr/command/Command.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,8 @@ class GenerateTreeCommand(
3636

3737
private fun getProjectPath(rootPath: String, relativePath: String?): String {
3838
val fileName = "project.godot"
39-
val path = Paths.get(rootPath, relativePath ?: "", fileName).toString()
40-
if (!File(path).exists()) throw InvalidGodotProject()
41-
return path
39+
val path = Paths.get(rootPath, relativePath ?: "", fileName)
40+
return path.toString()
4241
}
4342

4443
private fun getOutputPath(rootPath: String, packageName: String?): String {

src/main/kotlin/com/tomwyr/common/Errors.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ import kotlinx.serialization.Serializable
44

55
sealed class GodotKotlinTreeError : Exception() {
66
override fun getLocalizedMessage(): String = when (this) {
7-
is InvalidGodotProject -> "The project in which GodotNodeTree annotation was used isn't a valid Godot project directory"
87
is GeneratorError -> error.localizedMessage
98
}
109
}
1110

12-
class InvalidGodotProject : GodotKotlinTreeError()
13-
1411
class GeneratorError(val error: GodotNodeTreeError) : GodotKotlinTreeError()
1512

1613
@Serializable
1714
sealed class GodotNodeTreeError : Exception() {
1815
override fun getLocalizedMessage(): String = when (this) {
16+
is InvalidGodotProject -> "Godot project could not be found at path `$projectPath`."
1917
is ScanningScenesFailed -> "Unable to scan scene files for project at `$projectPath`."
2018
is ReadingSceneFailed -> "Unable to read contens of scene at `$scenePath`."
2119
is UnexpectedNodeParameters -> "A node with unexpected set of parameters encountered: $nodeParams."
@@ -24,6 +22,9 @@ sealed class GodotNodeTreeError : Exception() {
2422
}
2523
}
2624

25+
@Serializable
26+
class InvalidGodotProject(val projectPath: String) : GodotNodeTreeError()
27+
2728
@Serializable
2829
class ScanningScenesFailed(val projectPath: String) : GodotNodeTreeError()
2930

10.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)