<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Комментарии на: Обработка ошибок в PHP и исключения</title>
	<atom:link href="http://www.likhachev.net/2008/08/09/error-handling-and-exceptions/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.likhachev.net/2008/08/09/error-handling-and-exceptions/</link>
	<description>пишу что в голову взбредёт</description>
	<lastBuildDate>Wed, 07 Jul 2010 20:49:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>От: Knave</title>
		<link>http://www.likhachev.net/2008/08/09/error-handling-and-exceptions/comment-page-1/#comment-25690</link>
		<dc:creator>Knave</dc:creator>
		<pubDate>Tue, 17 Mar 2009 07:06:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.likhachev.net/?p=247#comment-25690</guid>
		<description>Вот как у меня выглядит функция вывода исключения:

&lt;code lang=&quot;php&quot;&gt;
	public function getHtml() {
		$html  = &#039;&lt;h1&gt;&lt;img src=&quot;/img/icons/burn.png&quot; width=&quot;16&quot; height=&quot;16&quot; alt=&quot;&quot; /&gt;&lt;b&gt;RedBox&lt;/b&gt; &#8212; ошибка&lt;/h1&gt;&#039;;
		$html .= &#039;&lt;p&gt;&lt;b&gt;&#039; . $this-&gt;message . &#039;&lt;/b&gt;&lt;/p&gt;&#039;;

		$html .= &#039;&lt;p&gt;Строка &#039; . $this-&gt;line . &#039; файла &#039; . $this-&gt;getFile() . &#039;&lt;/p&gt;&#039;;

		if (!empty($this-&gt;info) &amp;&amp; is_array($this-&gt;info)) {
			$html .= &#039;&lt;h2&gt;Дополнительная информация&lt;/h2&gt;&#039;;
			$html .= &#039;&lt;ul&gt;&#039;;

			foreach ($this-&gt;info as $lang =&gt; $text) {
				$geshi = new GeSHi($text, $lang);
				$geshi-&gt;set_header_type(GESHI_HEADER_DIV);
				$geshi-&gt;enable_classes(true);
				$geshi-&gt;set_overall_class(&#039;code-block&#039;);

				$html .= &#039;&lt;li&gt;&#039; . $lang . $geshi-&gt;parse_code() . &#039;&lt;/li&gt;&#039;;
			}

			$html .= &#039;&lt;/ul&gt;&#039;;
		}

		$stack = $this-&gt;getTrace();
		if (is_array($stack) &amp;&amp; count($stack) &gt; 0) {
			$html .= &#039;&lt;h2&gt;Стек вызова&lt;/h2&gt;&#039;;
			$html .= &#039;&lt;ul&gt;&#039;;

			foreach ($stack as $stackLine) {
				$html .= &#039;&lt;li&gt;&#039;;

				$html .= &#039;Строка &#039; . $stackLine[&#039;line&#039;] . &#039; файла &#039; . $stackLine[&#039;file&#039;];

				$code = &#039;&#039;;

				if(!empty($stackLine[&#039;class&#039;])) {
					$code .= $stackLine[&#039;class&#039;];
				}
				if(!empty($stackLine[&#039;type&#039;])) {
					$code .= $stackLine[&#039;type&#039;];
				}
				if(!empty($stackLine[&#039;function&#039;])) {
					$code .= $stackLine[&#039;function&#039;];
				}

				$args = array();
				foreach ($stackLine[&#039;args&#039;] as $arg) {
					if (is_string($arg))
						$args[] = &#039;&quot;&#039; . $arg . &#039;&quot;&#039;;
					elseif (is_array($arg))
						$args[] = print_r($arg, true);
					elseif (is_object($arg))
						$args[] = print_r($arg, true);
					elseif (is_bool($arg))
						$args[] = ($arg === true ? &#039;true&#039; : &#039;false&#039;);
					elseif (is_null($arg))
						$args[] = &#039;null&#039;;
					else
						$args[] = $arg;
				}
				$code .= &#039;(&#039; . implode(&#039;, &#039;, $args) . &#039;);&#039;;

				$geshi = new GeSHi($code, &#039;php&#039;);
				$geshi-&gt;set_header_type(GESHI_HEADER_DIV);
				$geshi-&gt;enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
				$geshi-&gt;set_tab_width(4);
				$geshi-&gt;enable_classes(true);
				$geshi-&gt;set_overall_class(&#039;code-block&#039;);
				$geshi-&gt;start_line_numbers_at($stackLine[&#039;line&#039;]);

				$html .= $geshi-&gt;parse_code();

				$html .= &#039;&lt;/li&gt;&#039;;
			}

			$html .= &#039;&lt;/ul&gt;&#039;;
		}

		return $html;
	}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Вот как у меня выглядит функция вывода исключения:</p>
<p><code lang="php"><br />
	public function getHtml() {<br />
		$html  = '<br />
<h1><img src="/img/icons/burn.png" width="16" height="16" alt="" /><b>RedBox</b> &mdash; ошибка</h1>
<p>';<br />
		$html .= '
<p><b>' . $this->message . '</b></p>
<p>';</p>
<p>		$html .= '
<p>Строка ' . $this->line . ' файла ' . $this->getFile() . '</p>
<p>';</p>
<p>		if (!empty($this->info) &#038;&#038; is_array($this->info)) {<br />
			$html .= '<br />
<h2>Дополнительная информация</h2>
<p>';<br />
			$html .= '
<ul>';</p>
<p>			foreach ($this->info as $lang => $text) {<br />
				$geshi = new GeSHi($text, $lang);<br />
				$geshi->set_header_type(GESHI_HEADER_DIV);<br />
				$geshi->enable_classes(true);<br />
				$geshi->set_overall_class('code-block');</p>
<p>				$html .= '
<li>' . $lang . $geshi->parse_code() . '</li>
<p>';<br />
			}</p>
<p>			$html .= '</ul>
<p>';<br />
		}</p>
<p>		$stack = $this->getTrace();<br />
		if (is_array($stack) &#038;&#038; count($stack) > 0) {<br />
			$html .= '<br />
<h2>Стек вызова</h2>
<p>';<br />
			$html .= '
<ul>';</p>
<p>			foreach ($stack as $stackLine) {<br />
				$html .= '
<li>';</p>
<p>				$html .= 'Строка ' . $stackLine['line'] . ' файла ' . $stackLine['file'];</p>
<p>				$code = '';</p>
<p>				if(!empty($stackLine['class'])) {<br />
					$code .= $stackLine['class'];<br />
				}<br />
				if(!empty($stackLine['type'])) {<br />
					$code .= $stackLine['type'];<br />
				}<br />
				if(!empty($stackLine['function'])) {<br />
					$code .= $stackLine['function'];<br />
				}</p>
<p>				$args = array();<br />
				foreach ($stackLine['args'] as $arg) {<br />
					if (is_string($arg))<br />
						$args[] = '"' . $arg . '"';<br />
					elseif (is_array($arg))<br />
						$args[] = print_r($arg, true);<br />
					elseif (is_object($arg))<br />
						$args[] = print_r($arg, true);<br />
					elseif (is_bool($arg))<br />
						$args[] = ($arg === true ? 'true' : 'false');<br />
					elseif (is_null($arg))<br />
						$args[] = 'null';<br />
					else<br />
						$args[] = $arg;<br />
				}<br />
				$code .= '(' . implode(', ', $args) . ');';</p>
<p>				$geshi = new GeSHi($code, 'php');<br />
				$geshi->set_header_type(GESHI_HEADER_DIV);<br />
				$geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);<br />
				$geshi->set_tab_width(4);<br />
				$geshi->enable_classes(true);<br />
				$geshi->set_overall_class('code-block');<br />
				$geshi->start_line_numbers_at($stackLine['line']);</p>
<p>				$html .= $geshi->parse_code();</p>
<p>				$html .= '</li>
<p>';<br />
			}</p>
<p>			$html .= '</ul>
<p>';<br />
		}</p>
<p>		return $html;<br />
	}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>От: Роман</title>
		<link>http://www.likhachev.net/2008/08/09/error-handling-and-exceptions/comment-page-1/#comment-23822</link>
		<dc:creator>Роман</dc:creator>
		<pubDate>Wed, 25 Feb 2009 16:49:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.likhachev.net/?p=247#comment-23822</guid>
		<description>Нашел откуда брать, но как построить строку кода, как в твоем примере? Можно из массива — до некоторых пор я так и делал, но тогда неверно отображаются параметры:
test(string so long...);
Неплохо было бы чтобы строки заключались в кавычки...
test(&#039;string so long...&#039;);
Но это возможно только в том случае, если брать стек из getTraceAsStrng - но как его разбирать на части не пойму...</description>
		<content:encoded><![CDATA[<p>Нашел откуда брать, но как построить строку кода, как в твоем примере? Можно из массива — до некоторых пор я так и делал, но тогда неверно отображаются параметры:<br />
test(string so long&#8230;);<br />
Неплохо было бы чтобы строки заключались в кавычки&#8230;<br />
test(&#8217;string so long&#8230;&#8217;);<br />
Но это возможно только в том случае, если брать стек из getTraceAsStrng &#8211; но как его разбирать на части не пойму&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>От: Роман</title>
		<link>http://www.likhachev.net/2008/08/09/error-handling-and-exceptions/comment-page-1/#comment-22799</link>
		<dc:creator>Роман</dc:creator>
		<pubDate>Tue, 17 Feb 2009 13:30:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.likhachev.net/?p=247#comment-22799</guid>
		<description>А откуда стек вызова брать?</description>
		<content:encoded><![CDATA[<p>А откуда стек вызова брать?</p>
]]></content:encoded>
	</item>
	<item>
		<title>От: Knave</title>
		<link>http://www.likhachev.net/2008/08/09/error-handling-and-exceptions/comment-page-1/#comment-3422</link>
		<dc:creator>Knave</dc:creator>
		<pubDate>Tue, 12 Aug 2008 05:42:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.likhachev.net/?p=247#comment-3422</guid>
		<description>Ну-ка, ну-ка, покажи как ты их обрабатываешь. :)</description>
		<content:encoded><![CDATA[<p>Ну-ка, ну-ка, покажи как ты их обрабатываешь. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>От: Alex_K</title>
		<link>http://www.likhachev.net/2008/08/09/error-handling-and-exceptions/comment-page-1/#comment-3404</link>
		<dc:creator>Alex_K</dc:creator>
		<pubDate>Mon, 11 Aug 2008 18:25:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.likhachev.net/?p=247#comment-3404</guid>
		<description>ивзращенец :))</description>
		<content:encoded><![CDATA[<p>ивзращенец :))</p>
]]></content:encoded>
	</item>
</channel>
</rss>
