From ec8500bd647aa82ffa39d249d44c0273a0a1294e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 24 Aug 2010 12:52:55 +0200 Subject: [PATCH] [FrameworkBundle] added support for previous exceptions in the exception pages --- .../Controller/ExceptionController.php | 11 +++- .../Debug/ExceptionManager.php | 40 ++++++++------ .../Resources/config/templating.xml | 1 + .../views/Exception/exception.json.php | 24 +++++++-- .../Resources/views/Exception/exception.php | 54 ++++++++++++++----- .../views/Exception/exception.txt.php | 21 +++++--- .../views/Exception/exception.xml.php | 20 ++++--- .../Resources/views/Exception/styles.php | 48 +++++++++++------ .../Resources/views/Exception/trace.php | 6 +-- .../Resources/views/Exception/trace.txt.php | 2 +- .../Resources/views/Exception/traces.php | 27 +++++++--- .../Resources/views/Exception/traces.txt.php | 6 +++ .../Resources/views/Exception/traces.xml.php | 8 +++ .../Templating/Helper/CodeHelper.php | 54 +++++++++++++++++-- src/Symfony/Component/CssSelector/Parser.php | 2 +- .../DependencyInjection/ContainerBuilder.php | 2 +- .../SessionStorage/PdoSessionStorage.php | 8 +-- src/Symfony/Component/Yaml/Yaml.php | 2 +- 18 files changed, 247 insertions(+), 89 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.txt.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.xml.php diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php index 19ffc082adde..95eb8a81f96f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php @@ -32,9 +32,18 @@ public function exceptionAction(ExceptionManager $manager) { $this['request']->setRequestFormat($manager->getFormat()); + $currentContent = ''; + while (false !== $content = ob_get_clean()) { + $currentContent .= $content; + } + $response = $this->render( 'FrameworkBundle:Exception:'.($this['kernel']->isDebug() ? 'exception' : 'error'), - array('manager' => $manager) + array( + 'manager' => $manager, + 'managers' => $manager->getLinkedManagers(), + 'currentContent' => $currentContent, + ) ); $response->setStatusCode($manager->getStatusCode()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php b/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php index c38f15bb96e6..e958311d0bb0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php +++ b/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php @@ -27,18 +27,23 @@ class ExceptionManager protected $exception; protected $request; protected $logger; - protected $currentContent; public function __construct(\Exception $exception, Request $request, DebugLoggerInterface $logger = null) { $this->exception = $exception; $this->request = $request; $this->logger = $logger; + } - $this->currentContent = ''; - while (false !== $content = ob_get_clean()) { - $this->currentContent .= $content; + public function getLinkedManagers() + { + $managers = array(); + $e = $this->exception; + while ($e = $e->getPrevious()) { + $managers[] = new $this($e, $this->request); } + + return $managers; } public function getException() @@ -46,11 +51,6 @@ public function getException() return $this->exception; } - public function getCurrentContent() - { - return $this->currentContent; - } - public function getLogger() { return $this->logger; @@ -126,13 +126,23 @@ public function getTraces() 'args' => array(), ); foreach ($this->exception->getTrace() as $entry) { + $class = ''; + $namespace = ''; + if (isset($entry['class'])) { + $parts = explode('\\', $entry['class']); + $class = array_pop($parts); + $namespace = implode('\\', $parts); + } + $traces[] = array( - 'class' => isset($entry['class']) ? $entry['class'] : '', - 'type' => isset($entry['type']) ? $entry['type'] : '', - 'function' => $entry['function'], - 'file' => isset($entry['file']) ? $entry['file'] : null, - 'line' => isset($entry['line']) ? $entry['line'] : null, - 'args' => isset($entry['args']) ? $entry['args'] : array(), + 'namespace' => $namespace, + 'short_class' => $class, + 'class' => isset($entry['class']) ? $entry['class'] : '', + 'type' => isset($entry['type']) ? $entry['type'] : '', + 'function' => $entry['function'], + 'file' => isset($entry['file']) ? $entry['file'] : null, + 'line' => isset($entry['line']) ? $entry['line'] : null, + 'args' => isset($entry['args']) ? $entry['args'] : array(), ); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml index 13c109312bcf..ddc5a9214e1a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml @@ -92,6 +92,7 @@ %debug.file_link_format% + %kernel.root_dir% diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.json.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.json.php index 4a4a2f6ecf69..0e4dc5f687ca 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.json.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.json.php @@ -1,9 +1,25 @@ - array( 'code' => $manager->getStatusCode(), - 'message' => $manager->getMessage(), - 'debug' => array( + 'message' => $manager->getName(), + 'exception' => array( 'name' => $manager->getName(), + 'message' => $manager->getMessage(), 'traces' => $manager->getTraces(), ), -))) ?> +)); + +if (count($managers)) { + $vars['exceptions'] = array(); + foreach ($managers as $i => $previous) { + $vars['exceptions'][] = array( + 'name' => $previous->getName(), + 'message' => $previous->getMessage(), + 'traces' => $previous->getTraces(), + ); + } +} + +echo json_encode($vars); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php index 001bc7463380..958c7f2710a1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.php @@ -7,10 +7,21 @@ render('FrameworkBundle:Exception:styles') ?> @@ -20,33 +31,50 @@ function toggle(id)
-

getStatusCode() ?> getStatusText() ?> - getName() ?>

', htmlspecialchars($manager->getMessage(), ENT_QUOTES, $view->getCharset())) ?>

+ +

getStatusCode() ?> getStatusText() ?> - getName() ?>

+ +
linked Exception 1): ?>s: +
    + $previous): ?> +
  • + getName() ?> » +
  • + +
+
+
-
+ render('FrameworkBundle:Exception:traces', array('manager' => $manager, 'position' => 0, 'count' => count($managers))) ?> + + $previous): ?> + render('FrameworkBundle:Exception:traces', array('manager' => $previous, 'position' => $i + 1, 'count' => count($managers))) ?> + + +

- Logs ... countErrors()): ?> - countErrors() ?> errors + countErrors() ?> errorcountErrors() > 1): ?>s + Logs »

-

Stack Trace

- - render('FrameworkBundle:Exception:traces', array('traces' => $manager->getTraces())) ?> +
-

Content of the Output ...

+
+

Content of the Output »

diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.txt.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.txt.php index 4d31f0aa975d..9c4e22a68999 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.txt.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.txt.php @@ -1,14 +1,19 @@ -[exception] getStatusCode().' | '.$manager->getStatusText().' | '.$manager->getName() ?> +[exception] getStatusCode().' | '.$manager->getStatusText().' | '.$manager->getName() ?> -[message] getMessage() ?> +[message] getMessage() ?> getTraces())): ?> -[stack trace] -getTraces() as $i => $trace): ?> -render('FrameworkBundle:Exception:trace.txt', array('i' => $i, 'trace' => $trace)) ?> +render('FrameworkBundle:Exception:traces', array('manager' => $manager, 'position' => 0, 'count' => count($managers))) ?> - + + + $previous): ?> +[linked exception] getName() ?>: getMessage() ?> + +render('FrameworkBundle:Exception:traces', array('manager' => $previous, 'position' => $i + 1, 'count' => count($managers))) ?> + -[symfony] v. (symfony-project.org) -[PHP] v. + +[symfony] v. (symfony-project.org) +[PHP] v. diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php index 620dc5e73821..cec8cd370106 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/exception.xml.php @@ -1,15 +1,13 @@ ', $view->getCharset())."\n" ?> - - getName() ?> - getMessage(), ENT_QUOTES, $view->getCharset()) ?> - -getTraces() as $i => $trace): ?> - - render('FrameworkBundle:Exception:trace.txt', array('i' => $i, 'trace' => $trace)) ?> - - + + render('FrameworkBundle:Exception:traces', array('manager' => $manager, 'position' => 0, 'count' => count($managers))) ?> + + + $previous): ?> + + render('FrameworkBundle:Exception:traces', array('manager' => $previous, 'position' => $i + 1, 'count' => count($managers))) ?> + - - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/styles.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/styles.php index 2afec7ee1b51..90719625e034 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/styles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/styles.php @@ -1,25 +1,41 @@ -body { margin: 0; padding: 0; margin-top: 30px; background-color: #eee } -body, td, th { font: 11px Verdana, Arial, sans-serif; color: #333 } +/* +Copyright (c) 2010, Yahoo! Inc. All rights reserved. +Code licensed under the BSD License: +http://developer.yahoo.com/yui/license.html +version: 3.1.2 +build: 56 +*/ +html{color:#000;background:#FFF;}body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}li{list-style:none;}caption,th{text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:normal;}q:before,q:after{content:'';}abbr,acronym{border:0;font-variant:normal;}sup{vertical-align:text-top;}sub{vertical-align:text-bottom;}input,textarea,select{font-family:inherit;font-size:inherit;font-weight:inherit;}input,textarea,select{*font-size:100%;}legend{color:#000;} + +/* +Symfony stylesheet +*/ +html { background: #eee } +body { font: 11px Verdana, Arial, sans-serif; color: #333 } +strong { font-weight: bold } +em { font-style: italic } a { color: #333 } -h1 { margin: 0; margin-top: 4px; font-weight: normal; font-size: 170%; letter-spacing: -0.03em; } -h2 { margin: 0; padding: 0; font-size: 90%; font-weight: normal; letter-spacing: -0.02em; } -h3 { margin: 0; padding: 0; margin-bottom: 10px; font-size: 110% } -ul { padding-left: 20px; list-style: decimal } -ul li { padding-bottom: 5px; margin: 0 } -ol { font-family: monospace; white-space: pre; list-style-position: inside; margin: 0; padding: 10px 0 } -ol li { margin: -5px; padding: 0 } +abbr { border-bottom: 1px dotted #000000; cursor: help } +h1 { font-size: 170%; letter-spacing: -0.03em; } +h2 { margin-top: 4px; font-size: 90%; letter-spacing: -0.02em; } +h3 { font-size: 130%; font-weight: bold; letter-spacing: -0.02em; } +h3 span { float: right; font-size: 80%; background: #eee; color: #333; padding: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } +ul { padding-left: 20px } +ul li { padding-bottom: 5px; list-style: decimal } +ol { font-family: monospace; white-space: pre; padding: 10px 0 } +ol li { margin: -5px; list-style: decimal; list-style-position: inside } ol .selected { font-weight: bold; background-color: #ffd; padding: 2px 0 } -table.vars { padding: 0; margin: 0; border: 1px solid #999; background-color: #fff; } -table.vars th { padding: 2px; background-color: #ddd; font-weight: bold } -table.vars td { padding: 2px; font-family: monospace; white-space: pre } p.error { padding: 10px; background-color: #f00; font-weight: bold; text-align: center; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; } p.error a { color: #fff } -#main { padding: 20px 25px; margin: 0; margin-bottom: 20px; border: 1px solid #ddd; background-color: #fff; text-align:left; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; min-width: 770px; max-width: 770px } -#message { padding: 20px 25px; margin: 0; margin-bottom: 5px; border: 1px solid #ddd; text-align:left; background-color: #c8e8f3; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; min-width: 770px; max-width: 770px } +.block { padding: 20px 25px; margin-bottom: 10px; border: 1px solid #ddd; background-color: #fff; text-align:left; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; min-width: 770px; max-width: 770px } +.traces { display: none; margin-top: 10px } +#message { margin-top: 30px; margin-bottom: 10px; padding: 20px 25px; border: 1px solid #ddd; text-align:left; background-color: #c8e8f3; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; min-width: 770px; max-width: 770px } #content { border: 1px solid #ddd; margin-top: 10px; padding: 7px; overflow: auto; } a.file_link { text-decoration: none; } a.file_link:hover { text-decoration: underline; } .code { overflow: auto; } img { vertical-align: middle; } -a img { border: 0; } -.error { background-color: #f66; padding: 1px 3px; color: #111; } +.error { background-color: #f66 } +.linked ul, .linked li { padding-left: 0; display: inline } +.linked li { padding-right: 7px } +#logs { margin-top: 10px } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.php index 07a21959e6b1..931312bde47e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.php @@ -1,10 +1,10 @@ - at (formatArgs($trace['args']) ?>)
+ at (formatArgs($trace['args']) ?>)
in formatFile($trace['file'], $trace['line']) ?> line - ...
-
    + »
    +
      fileExcerpt($trace['file'], $trace['line']) ?>
    diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.txt.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.txt.php index 0349e78858da..6a047d092063 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.txt.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/trace.txt.php @@ -1,5 +1,5 @@ - at (formatArgs($trace['args']) ?>) + at (formatArgsAsText($trace['args']) ?>) at n/a diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.php index 46239855a65f..cab4ab155e93 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.php @@ -1,7 +1,20 @@ -
      - $trace): ?> -
    • - render('FrameworkBundle:Exception:trace', array('i' => $i, 'trace' => $trace)) ?> -
    • - -
    +
    + 0): ?> +

    + / + getName() ?>: ', htmlspecialchars($manager->getMessage(), ENT_QUOTES, $view->getCharset())) ?> + »
    +

    + +

    Stack Trace

    + + + +
      + getTraces() as $i => $trace): ?> +
    • + render('FrameworkBundle:Exception:trace', array('prefix' => $position, 'i' => $i, 'trace' => $trace)) ?> +
    • + +
    +
    diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.txt.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.txt.php new file mode 100644 index 000000000000..1469b5a49439 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.txt.php @@ -0,0 +1,6 @@ +getTraces())): ?> +getTraces() as $i => $trace): ?> +render('FrameworkBundle:Exception:trace.txt', array('i' => $i, 'trace' => $trace)) ?> + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.xml.php b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.xml.php new file mode 100644 index 000000000000..40c494cf9674 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/views/Exception/traces.xml.php @@ -0,0 +1,8 @@ + +getTraces() as $i => $trace): ?> + + render('FrameworkBundle:Exception:trace.txt', array('i' => $i, 'trace' => $trace)) ?> + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index 2e8818d986c0..226a35c194e9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -21,15 +21,18 @@ class CodeHelper extends Helper { protected $fileLinkFormat; + protected $rootDir; /** * Constructor. * * @param string $fileLinkFormat The format for links to source files + * @param string $rootDir The project root directory */ - public function __construct($fileLinkFormat) + public function __construct($fileLinkFormat, $rootDir) { $this->fileLinkFormat = null !== $fileLinkFormat ? $fileLinkFormat : ini_get('xdebug.file_link_format'); + $this->rootDir = str_replace('\\', '/', $rootDir).'/'; } /** @@ -39,7 +42,7 @@ public function __construct($fileLinkFormat) * * @return string */ - public function formatArgs($args) + public function formatArgsAsText($args) { $result = array(); foreach ($args as $key => $value) { @@ -51,6 +54,46 @@ public function formatArgs($args) $formattedValue = sprintf("'%s'", $value); } elseif (null === $value) { $formattedValue = 'null'; + } elseif (false === $value) { + $formattedValue = 'false'; + } elseif (true === $value) { + $formattedValue = 'true'; + } else { + $formattedValue = $value; + } + + $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue); + } + + return implode(', ', $result); + } + + /** + * Formats an array as a string. + * + * @param array $args The argument array + * + * @return string + */ + public function formatArgs($args) + { + $result = array(); + foreach ($args as $key => $value) { + if (is_object($value)) { + $class = get_class($value); + $parts = explode('\\', $class); + $short = array_pop($parts); + $formattedValue = sprintf("object(%s)", $class, $short); + } elseif (is_array($value)) { + $formattedValue = sprintf("array(%s)", $this->formatArgs($value)); + } elseif (is_string($value)) { + $formattedValue = sprintf("'%s'", $value); + } elseif (null === $value) { + $formattedValue = 'null'; + } elseif (false === $value) { + $formattedValue = 'false'; + } elseif (true === $value) { + $formattedValue = 'true'; } else { $formattedValue = $value; } @@ -95,13 +138,18 @@ public function fileExcerpt($file, $line) */ public function formatFile($file, $line) { + if (0 === strpos($file, $this->rootDir)) { + $file = str_replace($this->rootDir, '', str_replace('\\', '/', $file)); + $file = sprintf('kernel.root_dir/%s', $this->rootDir, $file); + } + if (!$this->fileLinkFormat) { return $file; } $link = strtr($this->fileLinkFormat, array('%f' => $file, '%l' => $line)); - return sprintf('%s', $link, $file); + return sprintf('%s', $link, $this->rootDir, $file); } /** diff --git a/src/Symfony/Component/CssSelector/Parser.php b/src/Symfony/Component/CssSelector/Parser.php index 2cb1d31c988b..89724004b1b6 100644 --- a/src/Symfony/Component/CssSelector/Parser.php +++ b/src/Symfony/Component/CssSelector/Parser.php @@ -75,7 +75,7 @@ public function parse($string) } catch (\Exception $e) { $class = get_class($e); - throw new $class(sprintf('%s at %s -> %s', $e->getMessage(), implode($stream->getUsed(), ''), $stream->peek())); + throw new $class(sprintf('%s at %s -> %s', $e->getMessage(), implode($stream->getUsed(), ''), $stream->peek()), 0, $e); } } diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 9aac92414f36..ffef2846b81f 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -176,7 +176,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV return parent::get($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE); } catch (\InvalidArgumentException $e) { if (isset($this->loading[$id])) { - throw new \LogicException(sprintf('The service "%s" has a circular reference to itself.', $id)); + throw new \LogicException(sprintf('The service "%s" has a circular reference to itself.', $id), 0, $e); } if (!$this->hasDefinition($id) && isset($this->aliases[$id])) { diff --git a/src/Symfony/Component/HttpFoundation/SessionStorage/PdoSessionStorage.php b/src/Symfony/Component/HttpFoundation/SessionStorage/PdoSessionStorage.php index c009dfcf01ff..c2e9c63d79bb 100644 --- a/src/Symfony/Component/HttpFoundation/SessionStorage/PdoSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/SessionStorage/PdoSessionStorage.php @@ -108,7 +108,7 @@ public function sessionDestroy($id) $stmt->bindParam(1, $id, \PDO::PARAM_STR); $stmt->execute(); } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data. Message: %s', $e->getMessage())); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); } return true; @@ -135,7 +135,7 @@ public function sessionGC($lifetime) try { $this->db->query($sql); } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data. Message: %s', $e->getMessage())); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); } return true; @@ -184,7 +184,7 @@ public function sessionRead($id) return ''; } } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data. Message: %s', $e->getMessage())); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); } } @@ -214,7 +214,7 @@ public function sessionWrite($id, $data) $stmt->bindParam(2, $id, \PDO::PARAM_STR); $stmt->execute(); } catch (\PDOException $e) { - throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data. Message: %s', $e->getMessage())); + throw new \RuntimeException(sprintf('PDOException was thrown when trying to manipulate session data: %s', $e->getMessage()), 0, $e); } return true; diff --git a/src/Symfony/Component/Yaml/Yaml.php b/src/Symfony/Component/Yaml/Yaml.php index 5ce6c87f99f0..0e3c4b151e15 100644 --- a/src/Symfony/Component/Yaml/Yaml.php +++ b/src/Symfony/Component/Yaml/Yaml.php @@ -89,7 +89,7 @@ public static function load($input) try { $ret = $yaml->parse($input); } catch (\Exception $e) { - throw new \InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage())); + throw new \InvalidArgumentException(sprintf('Unable to parse %s: %s', $file ? sprintf('file "%s"', $file) : 'string', $e->getMessage()), 0, $e); } return $ret;