[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [donate/master] Added back the renderJsonErrorMessage function to ErrorHandler class.



commit 6b23adca8ddc15e001a472a03e837071a63a05b5
Author: Stephanie Kirtiadi <skirtiadi@xxxxxxxxxxxxxxx>
Date:   Mon May 20 13:54:55 2019 -0700

    Added back the renderJsonErrorMessage function to ErrorHandler class.
    
    Code review feedback.
    
    Issue #40961
---
 public/php_errors.log |  1 -
 src/ErrorHandler.php  | 14 ++++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/public/php_errors.log b/public/php_errors.log
deleted file mode 100644
index 547796ff..00000000
--- a/public/php_errors.log
+++ /dev/null
@@ -1 +0,0 @@
-[16-Apr-2019 23:27:39 UTC] PHP Notice:  Undefined index: email in /Users/skirtiadi/gr/tor.local/site/src/StripeController.php on line 73
diff --git a/src/ErrorHandler.php b/src/ErrorHandler.php
index 7541de6e..81b0ccd6 100644
--- a/src/ErrorHandler.php
+++ b/src/ErrorHandler.php
@@ -18,4 +18,18 @@ class ErrorHandler extends \Slim\Handlers\Error {
     $logger = $this->container->get('logger');
     $logger->error($message, array('exception' => $throwable, 'trace' => $throwable->getTrace()));
   }
+
+  protected function renderJsonErrorMessage(\Exception $exception)
+  {
+    $message = $exception->getMessage();
+    $response = array(
+      'errors' => array(
+        array(
+          'error_code' => $exception->getCode(),
+          'message' => $message
+        ),
+      ),
+    );
+    return json_encode($response, JSON_PRETTY_PRINT);
+  }
 }



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits