{"id":265493,"date":"2015-09-12T16:15:02","date_gmt":"2015-09-12T12:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=265493"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=265493","title":{"rendered":"\u041b\u043e\u0433\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439"},"content":{"rendered":"<p>       \u0412 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B5%D0%BD%D1%8C_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%81%D1%82%D0%B0\">\u0414\u043d\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430<\/a> \u0438 \u043f\u043e \u0441\u043b\u0435\u0434\u0430\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B5%D0%BD%D1%8C_%D1%82%D0%B5%D1%81%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D1%89%D0%B8%D0%BA%D0%B0\">\u0414\u043d\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430<\/a> \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u0438 \u0442\u0435\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u0432 \u0438\u0445 \u043e\u0431\u0449\u0435\u043c \u0434\u0435\u043b\u0435 \u2014 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u041f\u041e.<br \/>  \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0421++ \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438, \u0430 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u2014 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u043c.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u0430 \u043b\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Java \u044f \u043f\u0440\u0438\u0432\u044b\u043a \u043a \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u043c \u0432 \u0441\u0435\u0431\u0435 StackTrace \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435  <\/p>\n<blockquote>\n<pre> Exception in thread &quot;main&quot; java.lang.IllegalStateException: A book has a null property         at com.example.myproject.Author.getBookIds(Author.java:38)         at com.example.myproject.Bootstrap.main(Bootstrap.java:14) Caused by: java.lang.NullPointerException         at com.example.myproject.Book.getId(Book.java:22)         at com.example.myproject.Author.getBookIds(Author.java:35)         ... 1 more <\/pre>\n<\/blockquote>\n<p>  \u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u043d\u0430 \u0421++ \u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u0431\u044b\u043b \u043f\u043e\u0440\u0430\u0436\u0451\u043d \u043d\u0435\u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c\u044e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0432 \u043f\u043b\u0430\u043d\u0435 \u0432\u044b\u044f\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0440\u0438\u0447\u0438\u043d \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0439 \u043e\u0442\u043b\u0430\u0434\u043a\u0438. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0432\u0430\u0436\u043d\u044b\u0445 \u0442\u043e\u0447\u0435\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e \u043b\u043e\u0433\u0430\u043c \u043f\u043e\u043d\u044f\u0442\u044c \u0433\u0434\u0435 \u0436\u0435 \u0438\u043c\u0435\u043d\u043d\u043e \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a \u0438 \u043f\u0440\u0438\u0432\u0435\u043b\u043e \u043a \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e. <br \/>  \u0414\u0430\u043b\u0435\u0435 \u044f \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e \u0443\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u0443\u044e \u044d\u0432\u043e\u043b\u044e\u0446\u0438\u044e \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u0440\u043e\u0448\u0451\u043b \u0441\u0430\u043c.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043b\u0430\u0436\u0438\u0432\u0430\u0442\u044c \u0438 \u0443\u043b\u0443\u0447\u0448\u0430\u0442\u044c<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>void foo(int a) { \tif (a == 0) \t{ \t\tthrow runtime_error(&quot;foo throw because zero argument&quot;); \t} }  void bar(int a) { \tfoo(a - 10); }  int main() { \ttry \t{ \t\tfor (int i = 0; i &lt; 100; i++) \t\t{ \t\t\tbar(i); \t\t} \t} \tcatch (const exception &e) \t{ \t\tcerr &lt;&lt; &quot;Caught exception: &quot; &lt;&lt; e.what() &lt;&lt; endl; \t} \treturn 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0435 \u0437\u043d\u0430\u044f \u043d\u0438\u0447\u0435\u0433\u043e \u043e \u043f\u0443\u0442\u0438 \u0432\u044b\u0437\u043e\u0432\u0430 <b>foo<\/b> \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <b>bar<\/b> \u043e\u0447\u0435\u043d\u044c \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0441 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c  <\/p>\n<blockquote><p>Caught exception: foo throw because zero argument<\/p><\/blockquote>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u043b\u043e\u0433\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>void bar(int a) { \tcerr &lt;&lt; &quot;Calling foo(&quot; &lt;&lt; a - 10 &lt;&lt; &quot;)&quot; &lt;&lt; endl; \tfoo(a - 10); }  int main() { \ttry \t{ \t\tfor (int i = 0; i &lt; 100; i++) \t\t{ \t\t\tcerr &lt;&lt; &quot;Calling bar(&quot; &lt;&lt; i &lt;&lt; &quot;)&quot; &lt;&lt; endl; \t\t\tbar(i); \t\t} \t} \tcatch (const exception &e) \t{ \t\tcerr &lt;&lt; &quot;Caught exception: &quot; &lt;&lt; e.what() &lt;&lt; endl; \t} \treturn 0; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/b><\/p>\n<div class=\"spoiler_text\">\n<blockquote><p>Calling bar(0)<br \/>  Calling foo(-10)<br \/>  Calling bar(1)<br \/>  Calling foo(-9)<br \/>  Calling bar(2)<br \/>  Calling foo(-8)<br \/>  Calling bar(3)<br \/>  Calling foo(-7)<br \/>  Calling bar(4)<br \/>  Calling foo(-6)<br \/>  Calling bar(5)<br \/>  Calling foo(-5)<br \/>  Calling bar(6)<br \/>  Calling foo(-4)<br \/>  Calling bar(7)<br \/>  Calling foo(-3)<br \/>  Calling bar(8)<br \/>  Calling foo(-2)<br \/>  Calling bar(9)<br \/>  Calling foo(-1)<br \/>  Calling bar(10)<br \/>  Calling foo(0)<br \/>  Caught exception: foo throw because zero argument  <\/p><\/blockquote>\n<\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043d\u043e \u043b\u043e\u0433 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0447\u0435\u0440\u0435\u0441\u0447\u0443\u0440 \u0437\u0430\u0445\u043b\u0430\u043c\u043b\u0451\u043d\u043d\u044b\u043c. \u0410 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u043a\u043e\u0448\u043c\u0430\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044d\u0442\u043e \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c\u0441\u044f, \u0435\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b \u0432 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438, \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f 5 \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043b\u043e\u0433\u0430 \u0438 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0447\u0435\u0440\u0435\u0437 1000 \u0444\u0430\u0439\u043b\u043e\u0432. \u0418\u0442\u043e\u0433\u043e \u2014 5000 \u0441\u0442\u0440\u043e\u043a \u043b\u043e\u0433\u0430 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e, \u0438 10 \u0441\u0442\u0440\u043e\u043a \u043b\u043e\u0433\u0430 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435.<br \/>  \u0417\u0430 \u0432\u0440\u0435\u043c\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043b\u043e\u0433\u0430 \u043f\u0440\u043e\u043a\u043b\u044f\u0442\u0438\u044f \u043a\u043e\u043b\u043b\u0435\u0433-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u0430\u0437\u0434\u043d\u0438\u043a\u0430 \u0447\u0438\u0442\u0430\u044e\u0442 \u043c\u043e\u0439 \u043b\u043e\u0433 \u0438 \u043f\u0438\u0448\u0443\u0442 \u0431\u0430\u0433-\u0440\u0435\u043f\u043e\u0440\u0442, \u0437\u0430\u0433\u043e\u043d\u044f\u0442 \u043c\u043e\u044e \u043a\u0430\u0440\u043c\u0443 \u0432 \u043c\u0438\u043d\u0443\u0441 \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0441\u0442\u044c.<br \/>  \u0417\u043d\u0430\u0447\u0438\u0442 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u00ab\u043e\u0448\u0438\u0431\u043e\u0447\u043d\u044b\u0435\u00bb \u0432\u0435\u0442\u0432\u0438 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.<br \/>  \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u0447\u0442\u043e \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f \u043e\u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438\u043b\u0438 \u0432\u044b\u043a\u0438\u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435. \u0417\u043d\u0430\u0447\u0438\u0442 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043b\u043e\u0433 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u043e\u0442\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u043e \u0432\u044b\u0445\u043e\u0434\u0430 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u043e\u0434 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>void bar(int a) { \ttry \t{ \t\tfoo(a - 10); \t} \tcatch (const exception &e) \t{ \t\tstring msg = string(&quot;calling foo(&quot;) + to_string(a - 10) + &quot;) failed&quot;; \t\tthrow runtime_error(string(e.what()) + &quot;\\n&quot; + msg); \t} }  int main() { \ttry \t{ \t\tint i; \t\ttry \t\t{ \t\t\tfor (i = 0; i &lt; 100; i++) \t\t\t{ \t\t\t\tbar(i); \t\t\t} \t\t} \t\tcatch (const exception &e) \t\t{ \t\t\tstring msg = string(&quot;calling bar(&quot;) + to_string(i) + &quot;) failed&quot;; \t\t\tthrow runtime_error(string(e.what()) + &quot;\\n&quot; + msg); \t\t} \t} \tcatch (const exception &e) \t{ \t\tcerr &lt;&lt; &quot;Caught exception: &quot; &lt;&lt; e.what() &lt;&lt; endl; \t} \treturn 0; } <\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>Caught exception: foo throw because zero argument<br \/>  calling foo(0) failed<br \/>  calling bar(10) failed  <\/p><\/blockquote>\n<\/div>\n<\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438 \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u043f\u0438\u0448\u0443\u0442 \u0431\u0430\u0433-\u0440\u0435\u043f\u043e\u0440\u0442 \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0430\u0442 \u043a \u043d\u0435\u043c\u0443 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u0439, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u0439 \u0438 \u0447\u0438\u0441\u0442\u044b\u0439 \u043b\u043e\u0433. \u0410 \u0432\u043e\u0442 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u0441\u0442\u0430\u043b\u0430 \u0443\u0440\u043e\u0434\u043b\u0438\u0432\u043e\u0439 \u0438 \u043f\u043e\u0442\u0435\u0440\u044f\u043b\u0430 \u0432\u0441\u044e \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u2014 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u043a\u043e\u0434 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043e\u0448\u0438\u0431\u043e\u043a. \u0424\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043c\u044b \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u0441\u044c \u0447\u0443\u0442\u044c \u043b\u0438 \u043d\u0435 \u043a \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u043a\u043e\u0434\u043e\u0432 \u0432\u043e\u0437\u0432\u0440\u0430\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438 \u0436\u0435\u0441\u0442\u043e\u043a\u0438\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u0430\u043c \u0447\u0438\u0441\u0442\u043e\u0433\u043e C. \u0410 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0447\u0438\u0441\u0442\u044b\u0439 \u043b\u043e\u0433 \u0438 \u043d\u0435 \u0443\u0440\u043e\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0422.\u0435. \u043a\u0442\u043e-\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u0430 \u043d\u0430\u0441 \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0437\u0430\u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0449\u0435\u0435. \u0422\u0443\u0442 \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0434\u0445\u043e\u0434, <a href=\"http:\/\/habrahabr.ru\/post\/148781\/\">\u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u044b\u0439<\/a> \u043d\u0430 \u0425\u0430\u0431\u0440\u0435, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u0437\u0430\u043f\u0438\u0441\u044c \u043b\u043e\u0433\u043e\u0432 \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430.<\/p>\n<p>  \u0418\u0442\u0430\u043a \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f:  <\/p>\n<ol>\n<li>\u0417\u0430\u0434\u0430\u043d\u0438\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043b\u043e\u0433\u0430<\/li>\n<li>\u0412\u044b\u0432\u043e\u0434 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f<\/li>\n<\/ol>\n<p>  \u0422\u0443\u0442 \u043d\u0430\u043c \u043d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <b>bool uncaught_exception()<\/b>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043a\u0430\u043a \u0440\u0430\u0437 \u0438 \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u0435\u0441\u0442\u044c \u043b\u0438 \u043d\u0435\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041a\u043b\u0430\u0441\u0441 ExceptionContext<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>class ExceptionContext { public: \tExceptionContext(const std::string &msg); \t~ExceptionContext();  private: \tstd::string message; };  ExceptionContext::ExceptionContext(const std::string &msg): message(msg) {}  ExceptionContext::~ExceptionContext() { \tif (std::uncaught_exception()) \t{ \t\tstd::cerr &lt;&lt; message &lt;&lt; std::endl; \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>void bar(int a) { \tExceptionContext e(string(&quot;calling foo(&quot;) + to_string(a - 10) + &quot;)&quot;); \tfoo(a - 10); }  int main() { \ttry \t{ \t\tfor (int i = 0; i &lt; 100; i++) \t\t{ \t\t\tExceptionContext e(string(&quot;calling bar(&quot;) + to_string(i) + &quot;)&quot;); \t\t\tbar(i); \t\t} \t} \tcatch (const exception &e) \t{ \t\tcerr &lt;&lt; &quot;Caught exception: &quot; &lt;&lt; e.what() &lt;&lt; endl;http:\/\/habrahabr.ru\/topic\/edit\/266729\/# \t} \treturn 0; } <\/code><\/pre>\n<p>  <\/p>\n<blockquote><p>calling foo(0)<br \/>  calling bar(10)<br \/>  Caught exception: foo throw because zero argument<\/p><\/blockquote>\n<\/div>\n<\/div>\n<p>  \u0412\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0441\u043e\u0447\u0435\u0442\u0430\u0435\u0442 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u044c \u043b\u043e\u0433\u0430 (\u043b\u043e\u0433\u0438\u0440\u0443\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043f\u0430\u0432\u0448\u0443\u044e \u0432\u0435\u0442\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f) \u0441 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b (\u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u0440\u0430\u0437\u043d\u0435\u0441\u0435\u043d\u044b, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u043e\u0434 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u043e\u0439). \u0422\u0435\u043f\u0435\u0440\u044c \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0438 \u043c\u0435\u043d\u044f \u043f\u0440\u043e\u043a\u043b\u0438\u043d\u0430\u0442\u044c.<br \/>  \u0412\u043e\u043e\u0431\u0449\u0435-\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0446\u0435\u043b\u044c \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u0430, \u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0439\u0442\u0438 \u043f\u043e \u043f\u0443\u0442\u0438 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0445 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0439, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0443\u0436\u0435 \u0443\u043f\u043e\u043c\u044f\u043d\u0443\u0442\u043e\u0433\u043e <a href=\"http:\/\/habrahabr.ru\/post\/148781\/\">\u043f\u043e\u0441\u0442\u0430<\/a>.<br \/>  \u042f \u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u0432\u0441\u0435\u0433\u043e \u0434\u0432\u0430 \u043c\u043e\u043c\u0435\u043d\u0442\u0430:  <\/p>\n<ol>\n<li>\u0412\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043b\u043e\u0433\u0433\u0435\u0440\u0430\u043c\u0438<\/li>\n<li>\u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c<\/li>\n<\/ol>\n<p>  \u0420\u0430\u0441\u043f\u0435\u0447\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u0435 \u043b\u043e\u0433\u0430 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0432 <b>cerr<\/b> \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0443\u0434\u043e\u0431\u043d\u043e \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435\u043c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c \u0442\u0440\u0443\u0434\u043e\u043c \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0434\u043b\u044f \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0435\u0433\u043e \u0435\u0449\u0451 \u043a\u0443\u0434\u0430-\u043d\u0438\u0431\u0443\u0434\u044c (\u0434\u0430 \u0445\u043e\u0442\u044c \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443, \u0440\u0430\u0437 \u0443\u0436 \u043c\u044b \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0442\u0438\u043b\u0438 \u0435\u0433\u043e \u043e\u0431\u044a\u0451\u043c!). \u041e\u043f\u044f\u0442\u044c \u0436\u0435, \u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u043b\u0438 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0435 \u0441\u043f\u0435\u0446\u044d\u0444\u0444\u0435\u043a\u0442\u044b \u0432\u0440\u043e\u0434\u0435 \u0441\u0442\u0440\u043e\u043a \u043b\u043e\u0433\u0430 \u0432\u043f\u0435\u0440\u0435\u043c\u0435\u0448\u043a\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0442\u0435\u043f\u0435\u0440\u044c \u043a\u043b\u0430\u0441\u0441 <b>ExceptionContext<\/b> \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0433\u0438 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f, \u0430 \u043d\u0430\u0440\u0443\u0436\u0443 \u0432\u044b\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u0443, \u043d\u0430 \u043c\u0430\u043d\u0435\u0440 <a href=\"http:\/\/www.tutorialspoint.com\/java\/lang\/throwable_printstacktrace.htm\">printStackTrace<\/a> \u0438\u0437 Java.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0442\u043e\u043a\u043e\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 (\u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0421++11)<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code>class ExceptionContext { public: \tExceptionContext(const std::string &msg); \t~ExceptionContext();  \tstatic void Print(); \/\/! \u0412\u044b\u0432\u043e\u0434 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0432 cerr \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0447\u0438\u0441\u0442\u043a\u043e\u0439. private: \tstd::string message; \tstatic thread_local std::string global_context; \/\/! \u0425\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0442\u043e\u043a\u0430. };  ExceptionContext::ExceptionContext(const std::string &msg): message(msg) {}  ExceptionContext::~ExceptionContext() { \tif (std::uncaught_exception()) \t{ \t\tglobal_context += message + std::string(&quot;\\n&quot;); \t} }  void ExceptionContext::Print() { \tstd::cerr &lt;&lt; global_context &lt;&lt; std::endl; \tglobal_context.clear(); }  thread_local std::string ExceptionContext::global_context = std::string(&quot;&quot;); <\/code><\/pre>\n<p>  \u0410 catch-\u0431\u043b\u043e\u043a \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:  <\/p>\n<pre><code>\tcatch (const exception &e) \t{ \t\tcerr &lt;&lt; &quot;Caught exception: &quot; &lt;&lt; e.what() &lt;&lt; endl; \t\tExceptionContext::Print(); \t} <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041e\u0442 \u0421++11 \u0437\u0434\u0435\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 <b>thread_local<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442 \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442 <b>global_context<\/b> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439, \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0447\u043b\u0435\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0430 \u0438 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432.<\/p>\n<p>  \u0425\u043e\u0440\u043e\u0448\u0438\u0445 \u0432\u0441\u0435\u043c \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445, \u0447\u0438\u0441\u0442\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u0447\u0438\u0442\u0430\u0435\u043c\u044b\u0445 \u043b\u043e\u0433\u043e\u0432 \u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u043f\u0435\u0445\u043e\u0432 \u0432 \u0440\u0430\u0431\u043e\u0442\u0435!               <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/266729\/\"> http:\/\/habrahabr.ru\/post\/266729\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u0412 \u043f\u0440\u0435\u0434\u0434\u0432\u0435\u0440\u0438\u0438 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B5%D0%BD%D1%8C_%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%81%D1%82%D0%B0\">\u0414\u043d\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430<\/a> \u0438 \u043f\u043e \u0441\u043b\u0435\u0434\u0430\u043c <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%94%D0%B5%D0%BD%D1%8C_%D1%82%D0%B5%D1%81%D1%82%D0%B8%D1%80%D0%BE%D0%B2%D1%89%D0%B8%D0%BA%D0%B0\">\u0414\u043d\u044f \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0449\u0438\u043a\u0430<\/a> \u0445\u043e\u0447\u0443 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0436\u0438\u0437\u043d\u044c \u0438 \u0442\u0435\u043c \u0438 \u0434\u0440\u0443\u0433\u0438\u043c \u0432 \u0438\u0445 \u043e\u0431\u0449\u0435\u043c \u0434\u0435\u043b\u0435 \u2014 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u043e\u0442\u043b\u0430\u0434\u043a\u0435 \u041f\u041e.<br \/>  \u0410 \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043e \u0442\u043e\u043c \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0421++ \u0431\u043e\u043b\u0435\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u044b\u043c\u0438, \u0430 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043e\u043a \u2014 \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u044b\u043c.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-265493","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265493","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=265493"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/265493\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=265493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=265493"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=265493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}