Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:recycle: Simplify formatted kernel errors https://github.com/siyuan-note/siyuan/issues/20246

Daniele4357fb04604
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index 7765c56067..72fa9a4e70 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -367,7 +367,7 @@ func setNodeAttrs0(node *ast.Node, nameValues map[string]string, boxID string) (
for name := range nameValues {
switch strings.ToLower(name) {
case "bookmark", "tags":
- err = errors.New(fmt.Sprintf(Conf.Language(390), name))
+ err = fmt.Errorf(Conf.Language(390), name)
return
}
}
diff --git a/kernel/model/import.go b/kernel/model/import.go
index fd49529c00..32e4a4e1cd 100644
--- a/kernel/model/import.go
+++ b/kernel/model/import.go
@@ -341,7 +341,7 @@ func checkEncryptedImportFlashcards(tree *parse.Tree, sourcePath string, encrypt
if "" == title {
title = filepath.Base(sourcePath)
}
- return errors.New(fmt.Sprintf(Conf.Language(386), htmlstd.EscapeString(title)))
+ return fmt.Errorf(Conf.Language(386), htmlstd.EscapeString(title))
}
// importedBlockDocTitles 建立本次导入块 ID 到所属文档标题的映射,供闪卡卡片反查文档。
@@ -375,7 +375,7 @@ func checkEncryptedImportDeck(unzipRootPath string, trees map[string]*parse.Tree
if nil != loadErr || nil == deck {
// 牌组无法解析时仍要拒绝导入,此时无法指出具体文档,只报告包内牌组路径
logging.LogErrorf("load imported deck [%s] failed: %s", storageRiffDir, loadErr)
- return errors.New(fmt.Sprintf(Conf.Language(385), filepath.ToSlash(filepath.Join("storage", "riff"))))
+ return fmt.Errorf(Conf.Language(385), filepath.ToSlash(filepath.Join("storage", "riff")))
}
var deckDocs []string
@@ -395,14 +395,14 @@ func checkEncryptedImportDeck(unzipRootPath string, trees map[string]*parse.Tree
}
if 0 == len(deckDocs) {
// 牌组存在但没有可定位的卡片,退回报告包内牌组路径
- return errors.New(fmt.Sprintf(Conf.Language(385), filepath.ToSlash(filepath.Join("storage", "riff"))))
+ return fmt.Errorf(Conf.Language(385), filepath.ToSlash(filepath.Join("storage", "riff")))
}
deckDocs = gulu.Str.RemoveDuplicatedElem(deckDocs)
sort.Strings(deckDocs)
if 5 < len(deckDocs) {
deckDocs = append(deckDocs[:5], "...")
}
- return errors.New(fmt.Sprintf(Conf.Language(385), htmlstd.EscapeString(strings.Join(deckDocs, ", "))))
+ return fmt.Errorf(Conf.Language(385), htmlstd.EscapeString(strings.Join(deckDocs, ", ")))
}
func importSY0(zipPath, boxID, toPath string, createNotebook, autoDetect bool, sharedBlockIDs map[string]string,
@@ -954,7 +954,7 @@ func importSY0(zipPath, boxID, toPath string, createNotebook, autoDetect bool, s
// 只有"目标笔记本未解锁导致拒绝写盘"才替换为提示解锁的文案,其余写盘错误原样上抛,避免归因错误。
// 相对路径的父目录名来自导入包,需与文档标题一样转义后再进入错误消息。
if errors.Is(err, errImportedTreeBoxLocked) {
- err = errors.New(fmt.Sprintf(Conf.Language(388), htmlstd.EscapeString(finalRelPath)))
+ err = fmt.Errorf(Conf.Language(388), htmlstd.EscapeString(finalRelPath))
}
return
}