Skip to content

Commit 8a63dab

Browse files
committed
Refactor error message
1 parent 78969c5 commit 8a63dab

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

archinstall/main.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import importlib
44
import os
55
import sys
6+
import textwrap
67
import time
78
import traceback
89

@@ -100,6 +101,22 @@ def run() -> int:
100101
return 0
101102

102103

104+
def _error_message(exc: Exception) -> None:
105+
err = ''.join(traceback.format_exception(exc))
106+
error(err)
107+
108+
text = textwrap.dedent(
109+
"""\
110+
Archinstall experienced the above error. If you think this is a bug, please report it to
111+
https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".
112+
113+
Hint: To extract the log from a live ISO
114+
curl -F 'file=@/var/log/archinstall/install.log' https://0x0.st
115+
"""
116+
)
117+
warn(text)
118+
119+
103120
def main() -> int:
104121
rc = 0
105122
exc = None
@@ -110,20 +127,11 @@ def main() -> int:
110127
exc = e
111128
finally:
112129
if exc:
113-
err = ''.join(traceback.format_exception(exc))
114-
error(err)
115-
116-
text = (
117-
'Archinstall experienced the above error. If you think this is a bug, please report it to\n'
118-
'https://github.com/archlinux/archinstall and include the log file "/var/log/archinstall/install.log".\n\n'
119-
"Hint: To extract the log from a live ISO \ncurl -F 'file=@/var/log/archinstall/install.log' https://0x0.st\n"
120-
)
121-
122-
warn(text)
130+
_error_message(exc)
123131
rc = 1
124132

125-
sys.exit(rc)
133+
return rc
126134

127135

128136
if __name__ == '__main__':
129-
main()
137+
sys.exit(main())

0 commit comments

Comments
 (0)