From 7d5312d6b18270598e1d2dd4fd8a35e12eb988f1 Mon Sep 17 00:00:00 2001
From: Arpit Jain <3242828+arpitjain099@users.noreply.github.com>
Date: Thu, 8 Aug 2024 16:20:05 +0900
Subject: [PATCH] Update app.py

---
 .../docker/flask-playwright/app.py                    | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/evals/elsuite/multistep_web_tasks/docker/flask-playwright/app.py b/evals/elsuite/multistep_web_tasks/docker/flask-playwright/app.py
index 65386c6c9b..936b485551 100644
--- a/evals/elsuite/multistep_web_tasks/docker/flask-playwright/app.py
+++ b/evals/elsuite/multistep_web_tasks/docker/flask-playwright/app.py
@@ -59,8 +59,9 @@ def setup():
         client = page.context.new_cdp_session(page)  # talk to chrome devtools
         client.send("Accessibility.enable")  # to get AccessibilityTrees
     except Exception as e:
+        logger.error("Failed to start session", exc_info=True)
         return jsonify(
-            {"status": "error", "message": f"failed to start session (already started?): {e}"}
+            {"status": "error", "message": "failed to start session (already started?)"}
         )
     return jsonify({"status": "success", "message": "session started"})
 
@@ -116,10 +117,11 @@ def exec_command():
             }
         )
     except TypeError as e:
+        logger.error(f"Error returning results for command: {request.json['command']}: {e}")
         response = jsonify(
             {
                 "status": "success",
-                "message": f"could not return results of executed commands {request.json['command']}",
+                "message": f"An internal error has occurred while returning the results",
                 "content": str(e),
                 "url": page.url,
             }
@@ -161,10 +163,11 @@ def exec_commands():
             }
         )
     except TypeError as e:
+        logger.error(f"Error returning results of executed commands: {e}")
         response = jsonify(
             {
                 "status": "success",
-                "message": f"could not return results of executed commands {request.json['commands']}",
+                "message": f"An internal error has occurred while returning the results",
                 "content": str(e),
                 "url": page.url,
             }
@@ -188,7 +191,7 @@ def _execute_command(json_data: dict):
         logger.error(e)
         raise ValueError(
             f"Error executing command {command}",
-            jsonify({"status": "error", "message": f"error executing command {command}: {e}"}),
+            jsonify({"status": "error", "message": f"An internal error has occurred while executing the command"}),
         )