{"id":1431,"date":"2025-05-05T16:06:44","date_gmt":"2025-05-05T16:06:44","guid":{"rendered":"https:\/\/api.jquery.com\/?p=1431"},"modified":"2026-01-20T17:34:48","modified_gmt":"2026-01-20T17:34:48","slug":"jQuery.Deferred.getStackHook","status":"publish","type":"post","link":"https:\/\/api.jquery.com\/jQuery.Deferred.getStackHook\/","title":{"rendered":"jQuery.Deferred.getStackHook()"},"content":{"rendered":"<article id=\"jQuery-Deferred-getStackHook1\" class=\"entry method\"><h2 class=\"section-title\">\n<span class=\"name\">jQuery.Deferred.getStackHook()<\/span><span class=\"returns\">Returns: <a href=\"http:\/\/api.jquery.com\/Types\/#Error\">Error<\/a><\/span><span class=\"version-details\">version deprecated: <a href=\"\/category\/version\/3.7\/\">3.7<\/a>, removed: <a href=\"\/category\/version\/4.0\/\">4.0<\/a><\/span>\n<\/h2>\n<div class=\"entry-wrapper\">\n<p class=\"desc\"><strong>Description: <\/strong>Return an Error instance with a defined stack.<\/p>\n<ul class=\"signatures\"><li class=\"signature\">\n<h4 class=\"name\">\n<span class=\"version-details\">version added: <a href=\"\/category\/version\/3.0\/\">3.0<\/a><\/span><a id=\"jQuery-Deferred-getStackHook\" href=\"#jQuery-Deferred-getStackHook\"><span class=\"icon-link\"><\/span>jQuery.Deferred.getStackHook()<\/a>\n<\/h4>\n<ul><li><div class=\"null-signature\">This method does not accept any arguments.<\/div><\/li><\/ul>\n<\/li><\/ul>\n<div class=\"longdesc\" id=\"entry-longdesc\">\n    <div class=\"warning\">\n      <p>Note: This API has been deprecated in jQuery 3.7; please use the <a href=\"\/jQuery.Deferred.getErrorHook\/\"><code>jQuery.Deferred.getErrorHook<\/code><\/a> method instead.<\/p>\n    <\/div>\n    <div class=\"warning\">\n      <p>Note: This API is not defined by default, but jQuery will make use of it when defined.<\/p>\n    <\/div>\n    <p>See <a href=\"\/jQuery.Deferred.getErrorHook\/\"><code>jQuery.Deferred.getErrorHook<\/code><\/a> for the context why this API was created. Initially, we advised users to assign to it a function returning an error stack:<\/p>\n    <div class=\"syntaxhighlighter javascript\">\n\t<table>\n\t\t<tbody>\n\t\t\t<tr>\n\t\t\t\t\n\t\t\t\t<td class=\"gutter\">\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n1\">1<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n2\">2<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n3\">3<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n4\">4<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n5\">5<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n6\">6<\/div>\n\t\t\t\t\t\n\t\t\t\t\t\t<div class=\"line n7\">7<\/div>\n\t\t\t\t\t\n\t\t\t\t<\/td>\n\t\t\t\t\n\t\t\t\t<td class=\"code\">\n\t\t\t\t\t<pre><div class=\"container\"><div class=\"line\"><code>jQuery.Deferred.getStackHook = <span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span>(<span class=\"hljs-params\"><\/span>) <\/span>{<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>  <span class=\"hljs-keyword\">try<\/span> {<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>    <span class=\"hljs-keyword\">throw<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Error<\/span>( <span class=\"hljs-string\">\"Exception in jQuery.Deferred\"<\/span> );<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>  } <span class=\"hljs-keyword\">catch<\/span> ( err ) {<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>    <span class=\"hljs-keyword\">return<\/span> err.stack; <span class=\"hljs-comment\">\/\/ stack property returned here<\/span><\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>  }<\/code><\/div><\/div><div class=\"container\"><div class=\"line\"><code>};<\/code><\/div><\/div><\/pre>\n\t\t\t\t<\/td>\n\t\t\t<\/tr>\n\t\t<\/tbody>\n\t<\/table>\n<\/div>\n\n    <p>However, when such a stack is then logged by jQuery from inside of <a href=\"\/jQuery.Deferred.exceptionHook\/\"><code>jQuery.Deferred.exceptionHook<\/code><\/a>, the browser won't apply source maps. Therefore, we changed the recommendation to return the full error object itself. To make it clearer, the API was also renamed.<\/p>\n  <\/div>\n<\/div><\/article>","protected":false},"excerpt":{"rendered":"<p>Return an Error instance with a defined stack.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,112,61,102],"tags":[],"class_list":["post-1431","post","type-post","status-publish","format-standard","hentry","category-deferred-object","category-deprecated-37","category-removed","category-102"],"_links":{"self":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts\/1431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/comments?post=1431"}],"version-history":[{"count":1,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts\/1431\/revisions"}],"predecessor-version":[{"id":1432,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/posts\/1431\/revisions\/1432"}],"wp:attachment":[{"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/media?parent=1431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/categories?post=1431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/api.jquery.com\/wp-json\/wp\/v2\/tags?post=1431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}