Commit f71a10c5 by Jon Soifer Committed by Tianqi Chen

properly extract error type from windows error message (#4780)

Co-authored-by: Jon Soifer <jonso@microsoft.com>
parent 00ec7f9c
......@@ -194,6 +194,23 @@ def _find_error_type(line):
-------
name : str The error name
"""
if sys.platform == "win32":
# Stack traces aren't logged on Windows due to a DMLC limitation,
# so we should try to get the underlying error another way.
# DMLC formats errors "[timestamp] file:line: ErrorMessage"
# ErrorMessage is usually formatted "ErrorType: message"
# We can try to extract the error type using the final ":"
end_pos = line.rfind(":")
if end_pos == -1:
return None
start_pos = line.rfind(":", 0, end_pos)
if start_pos == -1:
return None
err_name = line[start_pos + 1 : end_pos].strip()
if _valid_error_name(err_name):
return err_name
return None
else:
end_pos = line.find(":")
if end_pos == -1:
return None
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment