Skip to content

Commit 4495873

Browse files
committed
fix(DatabaseInsCommand): add error handling and notify on failure
1 parent e02b027 commit 4495873

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/highlight/CodeHighlightSketch.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ class CodeHighlightSketch(
6262

6363
editor.component.isOpaque = true
6464

65-
editorFragment = EditorFragment(editor, editorLineThreshold)
65+
if (ideaLanguage?.displayName == "DevIn") {
66+
editorFragment = EditorFragment(editor, 1)
67+
} else {
68+
editorFragment = EditorFragment(editor, editorLineThreshold)
69+
}
70+
6671
add(editorFragment!!.getContent(), BorderLayout.CENTER)
6772

6873
if (textLanguage != null && textLanguage?.lowercase() != "markdown" && ideaLanguage != PlainTextLanguage.INSTANCE) {

core/src/main/resources/genius/en/code/repair-diff.vm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Here is the original code: ${context.oldCode}
44

55
Here is the patched code:
66

7-
${context.patch}
7+
${context.patchedCode}

core/src/main/resources/genius/zh/code/repair-diff.vm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ Here is the original code: ${context.oldCode}
44

55
Here is the patched code:
66

7-
${context.patch}
7+
${context.patchedCode}

core/src/main/resources/genius/zh/code/sketch.vm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ have created a routes.py and main.js file, and updated the main.html file.
5151
</user.question>
5252
<you.anwser.step1>
5353
// In this step 1, you should analysis the context information is enough or not, if not, you should call DevIn tool
54-
// to get the context information
54+
// to get the context information.
5555
// For example:
5656
为了帮助您创建基于 Python 的照片存储应用程序,我需要了解更多关于您的代码库的信息。请允许我调用工具来获取上下文信息。请执行以下 DevIn 代码:
5757
<devin>
5858
/dir:src
5959
/localSearch:photo
6060
</devin>
61+
// If the context information is still not enough, you should ask the user to provide more information
6162
</you.anwser.step1>
6263
<user.anwser.step1>
6364
// waiting for user send the tool execute result

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/DatabaseInsCommand.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package cc.unitmesh.devti.language.compiler.exec
22

3+
import cc.unitmesh.devti.AutoDevNotifications
34
import cc.unitmesh.devti.devin.InsCommand
45
import cc.unitmesh.devti.devin.dataprovider.BuiltinCommand
56
import com.intellij.openapi.project.Project
@@ -18,8 +19,13 @@ class DatabaseInsCommand(val myProject: Project, private val prop: String, priva
1819
listOf()
1920
}
2021

21-
val result = ToolchainFunctionProvider.lookup("DatabaseFunctionProvider")
22-
?.execute(myProject, prop, args, emptyMap())
22+
val result = try {
23+
ToolchainFunctionProvider.lookup("DatabaseFunctionProvider")
24+
?.execute(myProject, prop, args, emptyMap())
25+
} catch (e: Exception) {
26+
AutoDevNotifications.notify(myProject, "Error: ${e.message}")
27+
return "Error: ${e.message}"
28+
}
2329

2430
return result?.toString() ?: "No database provider found"
2531
}

0 commit comments

Comments
 (0)