Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Spack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eic_tools
Spack
Commits
53feb12e
Commit
53feb12e
authored
9 years ago
by
Todd Gamblin
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup and consolidate error handling
parent
b9746de5
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bin/spack
+1
-8
1 addition, 8 deletions
bin/spack
lib/spack/spack/build_environment.py
+4
-0
4 additions, 0 deletions
lib/spack/spack/build_environment.py
lib/spack/spack/error.py
+15
-0
15 additions, 0 deletions
lib/spack/spack/error.py
lib/spack/spack/package.py
+1
-10
1 addition, 10 deletions
lib/spack/spack/package.py
with
21 additions
and
18 deletions
bin/spack
+
1
−
8
View file @
53feb12e
...
@@ -126,14 +126,7 @@ def main():
...
@@ -126,14 +126,7 @@ def main():
try
:
try
:
return_val
=
command
(
parser
,
args
)
return_val
=
command
(
parser
,
args
)
except
SpackError
,
e
:
except
SpackError
,
e
:
if
spack
.
debug
:
e
.
die
()
# In debug mode, raise with a full stack trace.
raise
elif
e
.
long_message
:
tty
.
die
(
e
.
message
,
e
.
long_message
)
else
:
tty
.
die
(
e
.
message
)
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
sys
.
stderr
.
write
(
'
\n
'
)
sys
.
stderr
.
write
(
'
\n
'
)
tty
.
die
(
"
Keyboard interrupt.
"
)
tty
.
die
(
"
Keyboard interrupt.
"
)
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/build_environment.py
+
4
−
0
View file @
53feb12e
...
@@ -280,6 +280,10 @@ def child_fun():
...
@@ -280,6 +280,10 @@ def child_fun():
# Use os._exit here to avoid raising a SystemExit exception,
# Use os._exit here to avoid raising a SystemExit exception,
# which interferes with unit tests.
# which interferes with unit tests.
os
.
_exit
(
0
)
os
.
_exit
(
0
)
except
spack
.
error
.
SpackError
,
e
:
e
.
die
()
except
:
except
:
# Child doesn't raise or return to main spack code.
# Child doesn't raise or return to main spack code.
# Just runs default exception handler and exits.
# Just runs default exception handler and exits.
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/error.py
+
15
−
0
View file @
53feb12e
...
@@ -22,6 +22,10 @@
...
@@ -22,6 +22,10 @@
# along with this program; if not, write to the Free Software Foundation,
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
##############################################################################
import
os
import
sys
import
llnl.util.tty
as
tty
import
spack
class
SpackError
(
Exception
):
class
SpackError
(
Exception
):
"""
This is the superclass for all Spack errors.
"""
This is the superclass for all Spack errors.
...
@@ -38,6 +42,17 @@ def long_message(self):
...
@@ -38,6 +42,17 @@ def long_message(self):
return
self
.
_long_message
return
self
.
_long_message
def
die
(
self
):
if
spack
.
debug
:
sys
.
excepthook
(
*
sys
.
exc_info
())
os
.
_exit
(
1
)
else
:
tty
.
error
(
self
.
message
)
if
self
.
long_message
:
print
self
.
long_message
os
.
_exit
(
1
)
def
__str__
(
self
):
def
__str__
(
self
):
msg
=
self
.
message
msg
=
self
.
message
if
self
.
long_message
:
if
self
.
long_message
:
...
...
This diff is collapsed.
Click to expand it.
lib/spack/spack/package.py
+
1
−
10
View file @
53feb12e
...
@@ -816,17 +816,8 @@ def real_work():
...
@@ -816,17 +816,8 @@ def real_work():
except
ProcessError
,
e
:
except
ProcessError
,
e
:
# Annotate with location of build log.
# Annotate with location of build log.
e
.
build_log
=
log_path
e
.
build_log
=
log_path
# One of the processes returned an error code.
# Suppress detailed stack trace here unless in debug mode
if
spack
.
debug
:
raise
e
else
:
tty
.
error
(
e
)
# Still need to clean up b/c there was an error.
cleanup
()
cleanup
()
os
.
_exit
(
1
)
raise
e
except
:
except
:
# other exceptions just clean up and raise.
# other exceptions just clean up and raise.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment