Skip to content

Commit

Permalink
Improved error message for users
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensbox committed Mar 2, 2019
1 parent f7472bd commit 0c7ae80
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/symlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ func CreateSymlink(cwd string, dir string) {

err := os.Symlink(cwd, dir)
if err != nil {
log.Fatal("Unable to create symlink. You must have SUDO privileges")
log.Fatalf(`
Unable to create new symlink.
Maybe symlink already exist. Try running removing existing symlink.
Try running "unlink %s" to remove existing symlink.
Maybe you do not have privilege to create symlink at %s.
Error: %s
`, dir, dir, err)
panic(err)
}
}
Expand All @@ -21,12 +27,24 @@ func RemoveSymlink(symlinkPath string) {

_, err := os.Lstat(symlinkPath)
if err != nil {
log.Fatalf("Unable to find symlink. You must have SUDO privileges - %v \n", err)
log.Fatalf(`
Unable to remove symlink.
Try running removing existing symlink.
Try running "unlink %s" to remove existing symlink.
Maybe you do not have privilege to remove symlink at %s.
Error: %s
`, symlinkPath, symlinkPath, err)
panic(err)
} else {
errRemove := os.Remove(symlinkPath)
if errRemove != nil {
log.Fatalf("Unable to remove symlink. You must have SUDO privileges - %v \n", err)
log.Fatalf(`
Unable to remove symlink.
Try running removing existing symlink.
Try running "unlink %s" to remove existing symlink.
Maybe you do not have privilege to remove symlink at %s.
Error: %s
`, symlinkPath, symlinkPath, errRemove)
panic(errRemove)
}
}
Expand Down

0 comments on commit 0c7ae80

Please sign in to comment.