Add spack API warning with file/line (#48416)
This commit is contained in:
parent
beadf06caa
commit
79027884c7
@ -15,6 +15,10 @@
|
||||
SHOW_BACKTRACE = False
|
||||
|
||||
|
||||
class SpackAPIWarning(UserWarning):
|
||||
"""Warning that formats with file and line number."""
|
||||
|
||||
|
||||
class SpackError(Exception):
|
||||
"""This is the superclass for all Spack errors.
|
||||
Subclasses can be found in the modules they have to do with.
|
||||
|
@ -503,9 +503,12 @@ def make_argument_parser(**kwargs):
|
||||
return parser
|
||||
|
||||
|
||||
def send_warning_to_tty(message, *args):
|
||||
def send_warning_to_tty(message, category, filename, lineno, file=None, line=None):
|
||||
"""Redirects messages to tty.warn."""
|
||||
tty.warn(message)
|
||||
if category is spack.error.SpackAPIWarning:
|
||||
tty.warn(f"{filename}:{lineno}: {message}")
|
||||
else:
|
||||
tty.warn(message)
|
||||
|
||||
|
||||
def setup_main_options(args):
|
||||
|
Loading…
Reference in New Issue
Block a user