mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 03:07:45 +08:00
improve error message when failed in Mkdir
This commit is contained in:
parent
5629020538
commit
4991e14dff
@ -59,10 +59,9 @@ func init() {
|
||||
}
|
||||
|
||||
// Mkdir creates directories recursively with given <path>.
|
||||
// The parameter <path> is suggested to be absolute path.
|
||||
// The parameter <path> is suggested to be an absolute path instead of relative one.
|
||||
func Mkdir(path string) error {
|
||||
err := os.MkdirAll(path, os.ModePerm)
|
||||
if err != nil {
|
||||
if err := os.MkdirAll(path, os.ModePerm); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
@ -9,6 +9,7 @@ package glog
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
"github.com/gogf/gf/internal/intlog"
|
||||
"github.com/gogf/gf/os/gfile"
|
||||
"github.com/gogf/gf/util/gconv"
|
||||
@ -191,7 +192,7 @@ func (l *Logger) SetPath(path string) error {
|
||||
if !gfile.Exists(path) {
|
||||
if err := gfile.Mkdir(path); err != nil {
|
||||
//fmt.Fprintln(os.Stderr, fmt.Sprintf(`[glog] mkdir "%s" failed: %s`, path, err.Error()))
|
||||
return err
|
||||
return gerror.Wrapf(err, `Mkdir "%s" failed in Pwd "%s"`, path, gfile.Pwd())
|
||||
}
|
||||
}
|
||||
l.config.Path = strings.TrimRight(path, gfile.Separator)
|
||||
|
@ -9,6 +9,7 @@ package gsession
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gogf/gf/container/gmap"
|
||||
"github.com/gogf/gf/errors/gerror"
|
||||
"github.com/gogf/gf/internal/intlog"
|
||||
"github.com/gogf/gf/internal/json"
|
||||
"os"
|
||||
@ -55,7 +56,7 @@ func NewStorageFile(path ...string) *StorageFile {
|
||||
}
|
||||
if storagePath != "" {
|
||||
if err := gfile.Mkdir(storagePath); err != nil {
|
||||
panic(fmt.Sprintf("mkdir '%s' failed: %v", path[0], err))
|
||||
panic(gerror.Wrapf(err, `Mkdir "%s" failed in Pwd "%s"`, path, gfile.Pwd()))
|
||||
}
|
||||
}
|
||||
s := &StorageFile{
|
||||
|
Loading…
Reference in New Issue
Block a user