[Dynamic-to-Static ErrorMessage] Support dy2stat error message when call jit.save and polish error message (#28713)

* Support dy2stat error message when call jit.save;

* Polish dy2stat error message:
  (1) the original dygraph code is marked with (* user code *) ; 
  (2) "In user code:" -> "In transformed code:"
musl/fix_failed_unittests_in_musl
liym27 5 years ago committed by GitHub
parent f1074e3b19
commit 9881738e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -79,6 +79,11 @@ class TraceBackFrame(OriginInfo):
self.function_name = function_name
self.source_code = source_code
def formated_message(self):
return ' File "{}", line {}, in {}\n\t{}'.format(
self.location.filepath, self.location.lineno, self.function_name,
self.source_code.lstrip())
class ErrorData(object):
"""
@ -106,7 +111,7 @@ class ErrorData(object):
message_lines = []
# Step1: Adds header message to prompt users that the following is the original information.
header_message = "In user code:"
header_message = "In transformed code:"
message_lines.append(header_message)
message_lines.append("")

@ -69,9 +69,10 @@ class OriginInfo(object):
self.location, self.source_code, self.function_name)
def formated_message(self):
return ' File "{}", line {}, in {}\n\t{}'.format(
flag_for_origin_info = "(* user code *)"
return ' File "{}", line {}, in {} {}\n\t{}'.format(
self.location.filepath, self.location.lineno, self.function_name,
self.source_code.lstrip())
flag_for_origin_info, self.source_code.lstrip())
def as_frame(self):
return (self.location.filepath, self.location.lineno,

@ -609,6 +609,9 @@ class ConcreteProgram(object):
except BaseException as e:
# NOTE: If e is raised in compile time, e should be attached to ERROR_DATA here.
error.attach_error_data(e)
error_data = getattr(e, error.ERROR_DATA, None)
if error_data:
error_data.raise_new_exception()
raise
if outputs is not None:

Loading…
Cancel
Save