@@ -29,6 +29,10 @@ var LOCKFILENAME = 'session.lock'
2929var LOCKFILE = ( path:join $KRATOS-DIR $LOCKFILENAME )
3030var INITIALIZED = ( os:exists $LOCKFILE )
3131
32+ fn error-prefix {| name|
33+ print 'Kratos(init-' $name '): ' >& 2
34+ }
35+
3236fn cache-new {| name contents~|
3337 var c = ( path:join $KRATOS-DIR $name )
3438 if ( not ( os:exists $c )) {
@@ -53,28 +57,28 @@ fn init-xdg-dir-vars {
5357 try {
5458 use ../elvish-xdg/xdg-dirs
5559 xdg-dirs:populate-env
56- } catch e { echo $e [ 'reason' ] >& 2 }
60+ } catch e { error-prefix 'xdg-dir-vars' ; echo $e [ 'reason' ] >& 2 }
5761}
5862
5963fn init-session-default-shell {
6064 if $platform:is-windows { return }
6165 try {
6266 use ../elvish-as-default-shell/default-shell
6367 default-shell:init-session
64- } catch e { echo $e [ 'reason' ] >& 2 }
68+ } catch e { error-prefix 'session-default-shell' ; echo $e [ 'reason' ] >& 2 }
6569}
6670
6771fn init-session-automount-tmpfs {
6872 if $platform:is-windows { return }
6973 try {
7074 use ../elvish-tmpfs/automount
71- } catch e { echo $e [ 'reason' ] >& 2 }
75+ } catch e { error-prefix 'session-automount-tmpfs' ; echo $e [ 'reason' ] >& 2 }
7276}
7377
7478fn init-session-agent {
7579 try {
7680 agent:init-session
77- } catch e { echo $e [ 'reason' ] >& 2 }
81+ } catch e { error-prefix 'session-agent' ; echo $e [ 'reason' ] >& 2 }
7882}
7983
8084fn init-session-dirs {
@@ -91,7 +95,7 @@ fn init-session-dirs {
9195 if ( not ( os:exists $dir )) {
9296 try {
9397 os:makedirs $dir
94- } catch e { echo $e [ 'reason' ] >& 2 }
98+ } catch e { error-prefix 'session-dirs' ; echo $e [ 'reason' ] >& 2 }
9599 }
96100 }
97101}
@@ -122,7 +126,7 @@ fn init-instance-color-scheme {
122126 use github.com/chlorm/elvish-term/color-scheme
123127 # TODO: add an interface to allow user defined themes
124128 color-scheme:set $color-scheme:gitiles
125- } catch e { echo $e [ 'reason' ] >& 2 }
129+ } catch e { error-prefix 'instance-color-scheme' ; echo $e [ 'reason' ] >& 2 }
126130}
127131
128132fn init-instance-ls-colors {
@@ -132,30 +136,30 @@ fn init-instance-ls-colors {
132136 var lsCache = ( cache-new 'ls' $ls:get~ )
133137 try {
134138 ls:set & static=( cache-read $lsCache )
135- } catch e { echo $e [ 'reason' ] >& 2 }
136- } catch e { echo $e [ 'reason' ] >& 2 }
139+ } catch e { error-prefix 'instance-ls-colors:set' ; echo $e [ 'reason' ] >& 2 }
140+ } catch e { error-prefix 'instance-ls-colors' ; echo $e [ 'reason' ] >& 2 }
137141}
138142
139143fn init-instance-editor-env {
140144 use github.com/chlorm/elvish-auto-env/editor
141145 try {
142146 editor:set
143- } catch e { echo $e [ 'reason' ] >& 2 }
147+ } catch e { error-prefix 'instance-editor-env' ; echo $e [ 'reason' ] >& 2 }
144148}
145149fn init-instance-pager-env {
146150 try {
147151 use github.com/chlorm/elvish-auto-env/pager
148152 var pagerCache = ( cache-new 'pager' $pager:get~ )
149153 try {
150154 pager:set & static=( cache-read $pagerCache )
151- } catch e { echo $e [ 'reason' ] >& 2 }
152- } catch e { echo $e [ 'reason' ] >& 2 }
155+ } catch e { error-prefix 'instance-pager-env:set' ; echo $e [ 'reason' ] >& 2 }
156+ } catch e { error-prefix 'instance-pager-env' ; echo $e [ 'reason' ] >& 2 }
153157}
154158
155159fn init-instance-agent {
156160 try {
157161 agent:init-instance
158- } catch e { echo 'Agent: ' ( to-string $e [ 'reason' ]) >& 2 }
162+ } catch e { error-prefix 'instance-agent' ; echo $e [ 'reason' ] >& 2 }
159163}
160164
161165fn init-instance-nix-per-user-profile {
@@ -164,7 +168,7 @@ fn init-instance-nix-per-user-profile {
164168 use github.com/chlorm/elvish-util-wrappers/nix
165169 nix:user-profile-init
166170 }
167- } catch e { echo $e [ 'reason' ] >& 2 }
171+ } catch e { error-prefix 'instance-nix-per-user-profile' ; echo $e [ 'reason' ] >& 2 }
168172}
169173
170174fn init-instance-path {
0 commit comments