{"id":7975,"date":"2015-11-14T08:44:17","date_gmt":"2015-11-14T08:44:17","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/14\/sails-catch-global-adapter-errors-that-crash-the-server-open-source-projects-balderdashy-sails\/"},"modified":"2015-11-14T08:44:17","modified_gmt":"2015-11-14T08:44:17","slug":"sails-catch-global-adapter-errors-that-crash-the-server-open-source-projects-balderdashy-sails","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/14\/sails-catch-global-adapter-errors-that-crash-the-server-open-source-projects-balderdashy-sails\/","title":{"rendered":"Sails &#8211; catch global adapter errors that crash the server-open source projects balderdashy\/sails"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/882863292e2d3d2e593d747722c3efff?s=128&amp;d=identicon&amp;r=PG\" \/> <strong>Paul Scheltema<\/strong><\/p>\n<p>from the sails docs: http:\/\/sailsjs.org\/#!documentation\/config.500<\/p>\n<p>thats the error handling sails exposes from within the config<\/p>\n<p>if your error passes that, you can hook in there, otherwise you can hook in node&#8217;s process<\/p>\n<pre><code>process.on('uncaughtException', function (err) {\n  if (err.toString() === 'Error spawning mySQL connection') {\n    \/\/rende some error page\n  }\n})\n<\/code><\/pre>\n<p>if the exception thrown is async the only way to catch it is trough process<\/p>\n<p>do note however, that these kinds of errors are almost always unrecoverable, so crashing (and restarting) is the best approach<\/p>\n<p>most modules loaded use local variables and expose only a subset of their internals trough <code>module.exports<\/code>, unloading a module and restarting its local code can be done, but you would need to unload all dependant modules and all modules holding references to it also. Thats why the normal approach is to let it crash<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Paul Scheltema from the sails docs: http:\/\/sailsjs.org\/#!documentation\/config.500 thats the error handling sails exposes from within the config if your error passes that, you can hook in there, otherwise you can hook in node&#8217;s process process.on(&#8216;uncaughtException&#8217;, function (err) { if (err.toString() === &#8216;Error spawning mySQL connection&#8217;) { \/\/rende some error page } }) if the exception [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7975","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7975"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7975\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}