Fix crash when creating a new note fails

pull/83/head
Mickaël Menu 3 years ago
parent dc27a7dd7c
commit 7a7cb6a7d3
No known key found for this signature in database
GPG Key ID: 53D73664CD359895

@ -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