Skip to content

Commit 837f65b

Browse files
committed
fix(devti): handle missing example files with error message
- Replace throwing exception with returning error message for missing example files - Improve user experience by providing informative error instead of causing application crash
1 parent 7c55518 commit 837f65b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

core/src/main/kotlin/cc/unitmesh/devti/command/dataprovider/BuiltinCommand.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ enum class BuiltinCommand(
150150

151151
fun example(commandName: String): String {
152152
val inputStream = BuiltinCommand::class.java.getResourceAsStream("/agent/toolExamples/$commandName.devin")
153-
?: throw IllegalStateException("Example file not found: $commandName.devin")
153+
if (inputStream == null) {
154+
return "<DevInsError> Example file not found: $commandName.devin"
155+
}
154156

155157
return inputStream.use {
156158
it.readAllBytes().toString(StandardCharsets.UTF_8)

0 commit comments

Comments
 (0)