@@ -2,7 +2,7 @@ import { localInstance } from "src/i18n/locals";
22import FormPlugin from "src/main" ;
33import { FormService } from "../FormService" ;
44import CFormSuggestModal from "src/component/modal/CFormSuggestModal" ;
5- import { normalizePath } from "obsidian" ;
5+ import { normalizePath , Notice } from "obsidian" ;
66import { FormConfig } from "src/model/FormConfig" ;
77import { DEFAULT_SETTINGS } from "src/settings/PluginSettings" ;
88import { openFilePathDirectly } from "src/utils/openFilePathDirectly" ;
@@ -53,10 +53,15 @@ export class ApplicationCommandService {
5353 defaultTargetFolder : targetFolder ,
5454 fileType : "cform" ,
5555 onSubmit : async ( fileName , targetFolder ) => {
56- const formConfig = new FormConfig ( v4 ( ) )
57- const json = JSON . stringify ( formConfig , null , 2 ) ;
58- const file = await Files . createFile ( app , fileName , targetFolder , json ) ;
59- await openFilePathDirectly ( app , file . path , "modal" ) ;
56+ try {
57+ const formConfig = new FormConfig ( v4 ( ) )
58+ const json = JSON . stringify ( formConfig , null , 2 ) ;
59+ const file = await Files . createFile ( app , fileName , targetFolder , json ) ;
60+ await openFilePathDirectly ( app , file . path , "modal" ) ;
61+ } catch ( error ) {
62+ console . error ( "Error creating form file:" , error ) ;
63+ new Notice ( "create file " + fileName + " failed" , 5000 ) ;
64+ }
6065 modal . close ( ) ;
6166 }
6267 } )
0 commit comments