From df0779fb142b829061313bc03ee54434d5277cb0 Mon Sep 17 00:00:00 2001
From: Qiang Xue <qiang.xue@gmail.com>
Date: Fri, 14 Jun 2013 17:10:36 -0400
Subject: [PATCH] Added previous exception in toArray().

---
 framework/yii/base/Exception.php | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/framework/yii/base/Exception.php b/framework/yii/base/Exception.php
index fe497a7..19317ca 100644
--- a/framework/yii/base/Exception.php
+++ b/framework/yii/base/Exception.php
@@ -29,11 +29,24 @@ class Exception extends \Exception implements Arrayable
 	 */
 	public function toArray()
 	{
-		return array(
+		$array = array(
 			'type' => get_class($this),
 			'name' => $this->getName(),
 			'message' => $this->getMessage(),
 			'code' => $this->getCode(),
 		);
+		if (($prev = $this->getPrevious()) !== null) {
+			if ($prev instanceof self) {
+				$array['previous'] = $prev->toArray();
+			} else {
+				$array['previous'] = array(
+					'type' => get_class($prev),
+					'name' => 'Exception',
+					'message' => $prev->getMessage(),
+					'code' => $prev->getCode(),
+				);
+			}
+		}
+		return $array;
 	}
 }
--
libgit2 0.27.1