Skip to content

Commit 4e60227

Browse files
committed
Error Handling when TERM variable is invalid
1 parent 0d5a410 commit 4e60227

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

pkg/app/errors.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package app
22

33
import (
4+
"fmt"
5+
"os"
46
"strings"
57

68
"github.com/jesseduffield/lazygit/pkg/i18n"
@@ -31,6 +33,14 @@ func knownError(tr *i18n.TranslationSet, err error) (string, bool) {
3133
originalError: "getwd: no such file or directory",
3234
newError: tr.WorkingDirectoryDoesNotExist,
3335
},
36+
{
37+
originalError: "terminal entry not found: term not set",
38+
newError: tr.TermNotSet,
39+
},
40+
{
41+
originalError: "terminal entry not found: term not found",
42+
newError: fmt.Sprintf(tr.TermNotFound, os.Getenv("TERM")),
43+
},
3444
}
3545

3646
if mapping, ok := lo.Find(mappings, func(mapping errorMapping) bool {

pkg/i18n/english.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,8 @@ type TranslationSet struct {
499499
StashOptions string
500500
NotARepository string
501501
WorkingDirectoryDoesNotExist string
502+
TermNotSet string
503+
TermNotFound string
502504
ScrollLeft string
503505
ScrollRight string
504506
DiscardPatch string
@@ -1583,6 +1585,8 @@ func EnglishTranslationSet() *TranslationSet {
15831585
StashOptions: "Stash options",
15841586
NotARepository: "Error: must be run inside a git repository",
15851587
WorkingDirectoryDoesNotExist: "Error: the current working directory does not exist",
1588+
TermNotSet: "Error: TERM environment variable not set.",
1589+
TermNotFound: "Error: could not find terminal info for $TERM '%s'. Please check your TERM variable is set correctly.",
15861590
ScrollLeft: "Scroll left",
15871591
ScrollRight: "Scroll right",
15881592
DiscardPatch: "Discard patch",

vendor/github.com/gdamore/tcell/v2/terms_dynamic.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)