<?xml version="1.0" encoding="UTF-8"?>
<article>
  <body>Rails&#21193;&#24375;&#20250;#40&#12398;&#12475;&#12483;&#12471;&#12519;&#12531;&#12391;&#12418;&#35328;&#12356;&#12414;&#12375;&#12383;&#12364;&#12289;
&#12456;&#12521;&#12540;&#12364;&#30330;&#29983;&#12375;&#12383;&#26178;&#31561;&#12395;&#34920;&#31034;&#12373;&#12428;&#12427;backtrace&#12398;&#34920;&#31034;&#12399;&#12289;
&#12467;&#12531;&#12477;&#12540;&#12523;&#12398;&#12424;&#12358;&#12395;&#19978;&#12363;&#12425;&#19979;&#12395;&#27969;&#12428;&#12427;&#30011;&#38754;&#19978;&#12391;&#12399;
&#36890;&#24120;&#12398;&#36870;&#38918;&#12398;&#12411;&#12358;&#12364;&#36861;&#12356;&#12420;&#12377;&#12356;&#12392;&#24605;&#12356;&#12414;&#12377;&#12290;

&#12392;&#12356;&#12358;&#12371;&#12392;&#12391;&#12289;&#12385;&#12423;&#12387;&#12392;&#35430;&#12375;&#12395;&#12381;&#12398;&#12424;&#12358;&#12394;&#25369;&#21205;&#12395;&#12375;&#12390;&#12415;&#12414;&#12375;&#12383;&#12290;
&#20197;&#19979;&#12398;&#12424;&#12358;&#12394;&#12467;&#12540;&#12489;&#12434;&#23455;&#34892;&#12377;&#12427;&#12392;&#12486;&#12473;&#12488;&#12391;&#12365;&#12414;&#12377;&#12290;

ruby&gt;&gt;
class Exception
  def set_backtrace(bt)
    puts bt.reverse.map{|i|
      i.sub(/^([\/\.\w]+):(\d+)/,
        &quot;\e[33m\\1\e[m:\e[32m\\2\e[m&quot;)
    }.join(&quot;\n&quot;)
  end
end

def foo
  raise StandardError
end

def bar
  foo
end

bar
&lt;&lt;--

&#12371;&#12435;&#12394;&#24863;&#12376;&#12395;&#12289;&#12456;&#12521;&#12540;&#12364;&#30330;&#29983;&#12375;&#12383;&#22580;&#25152;&#12395;&#36817;&#12356;&#38918;&#12395;&#12289;
&#19979;&#12363;&#12425;&#19978;&#12395;&#12383;&#12393;&#12387;&#12390;&#12356;&#12367;&#24863;&#12376;&#12395;&#34920;&#31034;&#12373;&#12428;&#12414;&#12377;&#12290;

![ss](http://img.skitch.com/20090423-qwckwc9s3mw3bxjquhp8m7n8yf.png)

&#19978;&#12363;&#12425;&#19979;&#12398;backtrace&#12395;&#30446;&#12364;&#24931;&#12428;&#12390;&#12375;&#12414;&#12387;&#12390;&#12356;&#12427;&#12398;&#12391;&#12289;&#26368;&#21021;&#12399;&#36861;&#12356;&#12363;&#12369;&#12395;&#12367;&#12373;&#12434;&#24863;&#12376;&#12414;&#12377;&#12364;&#12289;&#19968;&#26086;&#24931;&#12428;&#12390;&#12375;&#12414;&#12360;&#12400;&#12289;&#12473;&#12479;&#12483;&#12463;&#12364;&#28145;&#12367;&#12390;&#30456;&#24403;&#12473;&#12463;&#12525;&#12540;&#12523;&#12450;&#12483;&#12503;&#12375;&#12394;&#12369;&#12428;&#12400;&#12456;&#12521;&#12540;&#12398;&#30330;&#29983;&#28304;&#12414;&#12391;&#12383;&#12393;&#12426;&#30528;&#12369;&#12394;&#12356;&#12392;&#12356;&#12358;&#22580;&#21512;&#12395;&#12399;&#33391;&#12373;&#12381;&#12358;&#12394;&#27671;&#12364;&#12375;&#12414;&#12377;&#12290;

stack&#12392;&#12356;&#12358;&#27010;&#24565;&#12398;&#12452;&#12513;&#12540;&#12472;&#12398;&#12379;&#12356;&#12391;&#12289;&#26032;&#12375;&#12356;&#12418;&#12398;&#12364;&#19978;&#12398;&#26041;&#12395;&#26469;&#12427;&#12424;&#12358;&#12395;&#12394;&#12387;&#12390;&#12356;&#12427;&#12398;&#12384;&#12392;&#24605;&#12356;&#12414;&#12377;&#12364;&#12289;&#23455;&#29992;&#19978;&#12399;&#26032;&#12375;&#12356;&#12418;&#12398;&#12364;&#19979;&#12395;&#12367;&#12427;&#12371;&#12398;&#12473;&#12479;&#12452;&#12523;&#12398;&#26041;&#12364;&#20415;&#21033;&#12391;&#12399;&#12394;&#12356;&#12391;&#12375;&#12423;&#12358;&#12363;&#12290;</body>
  <cached-tag-list>ruby memo idea</cached-tag-list>
  <comments-count type="integer">2</comments-count>
  <created-at type="datetime">2009-04-23T14:27:47+00:00</created-at>
  <daily-archive-id type="integer">1130</daily-archive-id>
  <filter-type>blue_stole</filter-type>
  <id type="integer">1450</id>
  <monthly-archive-id type="integer">151</monthly-archive-id>
  <pdf-digest nil="true"></pdf-digest>
  <permalink nil="true"></permalink>
  <published-at type="datetime">2009-04-23T04:04:00+00:00</published-at>
  <secret>a80bec54-73ba-4cd7-9b33-59ae85888738</secret>
  <title>backtrace&#12398;&#34920;&#31034;&#12399;&#36870;&#38918;&#12398;&#26041;&#12364;&#20415;&#21033;</title>
  <updated-at type="datetime">2009-04-23T14:31:54+00:00</updated-at>
  <user-id type="integer">1</user-id>
</article>
