From 8da89b8199997ce2002227ad77f6abefac5c6f9f Mon Sep 17 00:00:00 2001 From: WangZhen <23097963+0x45f@users.noreply.github.com> Date: Fri, 7 Apr 2023 14:22:54 +0800 Subject: [PATCH] Polish dy2st error message (#52527) --- python/paddle/jit/dy2static/error.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/python/paddle/jit/dy2static/error.py b/python/paddle/jit/dy2static/error.py index a28e67d0de4..5cad201d9eb 100644 --- a/python/paddle/jit/dy2static/error.py +++ b/python/paddle/jit/dy2static/error.py @@ -245,12 +245,18 @@ class ErrorData: # Simplify error value to improve readability if error is raised in runtime if self.in_runtime: - if int( - os.getenv(SIMPLIFY_ERROR_ENV_NAME, DEFAULT_SIMPLIFY_NEW_ERROR) - ): - self._simplify_error_value() - message_lines.append(str(self.error_value)) - return '\n'.join(message_lines) + try: + if int( + os.getenv( + SIMPLIFY_ERROR_ENV_NAME, DEFAULT_SIMPLIFY_NEW_ERROR + ) + ): + self._simplify_error_value() + except: + pass + else: + message_lines.append(str(self.error_value)) + return '\n'.join(message_lines) # Step2: Optimizes stack information with source code information of dygraph from user. user_code_traceback_index = [] -- GitLab