next : better error
This commit is contained in:
parent
78d33ae62d
commit
0fba550f1e
1 changed files with 4 additions and 4 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
package next
|
package next
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
@ -14,8 +13,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
CMD = cmd.Next
|
CMD = cmd.Next
|
||||||
SUMMARY = "create the next um file and open with emacsclient"
|
SUMMARY = "create the next um file and open with emacsclient"
|
||||||
|
NEXT_NUM_ERROR = "failed to find number in last file"
|
||||||
)
|
)
|
||||||
|
|
||||||
const FILE_REGEXP = `(?m)^([0-9]+)\.[^\.]*\.*md$`
|
const FILE_REGEXP = `(?m)^([0-9]+)\.[^\.]*\.*md$`
|
||||||
|
|
@ -42,7 +42,7 @@ func NumFromLast(l string) (string, error) {
|
||||||
res := fileRegexp.FindStringSubmatch(l)
|
res := fileRegexp.FindStringSubmatch(l)
|
||||||
num := ""
|
num := ""
|
||||||
if len(res) < 2 {
|
if len(res) < 2 {
|
||||||
return num, errors.New(last.NOT_FOUND_MSG)
|
return num, fmt.Errorf("%s: %s", NEXT_NUM_ERROR, l)
|
||||||
}
|
}
|
||||||
num = res[1]
|
num = res[1]
|
||||||
return num, nil
|
return num, nil
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue