Fix crash when creating a new note fails (#83)

pull/88/head
Mickaël Menu 3 years ago committed by GitHub
parent dc27a7dd7c
commit 977dc20bcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -42,15 +42,17 @@ func (cmd *New) Run(container *cli.Container) error {
Extra: cmd.Extra,
Date: time.Now(),
})
path := filepath.Join(notebook.Path, note.Path)
if err != nil {
var path string
if err == nil {
path = filepath.Join(notebook.Path, note.Path)
} else {
var noteExists core.ErrNoteExists
if !errors.As(err, &noteExists) {
return err
}
if confirmed, _ := container.Terminal.Confirm(
fmt.Sprintf("%s already exists, do you want to edit this note instead?", note.Path),
fmt.Sprintf("%s already exists, do you want to edit this note instead?", noteExists.Name),
true,
); !confirmed {
// abort...

Loading…
Cancel
Save