<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>difference between VERIFY_SUCCESS() and APP_ERROR_CHECK()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25279/difference-between-verify_success-and-app_error_check</link><description>Hello I am using the NRF52832 in ESB mode. I use both VERIFY_SUCCESS() and APP_ERROR_CHECK() within my code in various places but when am I supposed to use versus the other. For example, I use: 
 err_code = esb_init(); 
 VERIFY_SUCCESS(err_code); </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 18 Sep 2017 18:32:21 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25279/difference-between-verify_success-and-app_error_check" /><item><title>RE: difference between VERIFY_SUCCESS() and APP_ERROR_CHECK()</title><link>https://devzone.nordicsemi.com/thread/99616?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2017 18:32:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3aff1c7-19d7-48c4-8418-017a968a758b</guid><dc:creator>Ed</dc:creator><description>&lt;p&gt;Thank you, this is clear now&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: difference between VERIFY_SUCCESS() and APP_ERROR_CHECK()</title><link>https://devzone.nordicsemi.com/thread/99615?ContentTypeID=1</link><pubDate>Mon, 18 Sep 2017 18:27:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d823b18-75af-4af5-a533-749bdcc77131</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have included the relevant implementations of the macros from SDK14 to help you see the difference between them:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**@brief Macro for verifying statement to be false. It will cause the exterior function to return
 *        err_code if the statement is not false.
 *
 * @param[in]   statement   Statement to test.
 * @param[in]   err_code    Error value to return if test was invalid.
 *
 * @retval      nothing, but will cause the exterior function to return @p err_code if @p statement
 *              is true.
 */
#define VERIFY_FALSE(statement, err_code)   \
do                                          \
{                                           \
    if ((statement))                        \
    {                                       \
        return err_code;                    \
    }                                       \
} while (0)

/**@brief Macro for verifying that a function returned NRF_SUCCESS. It will cause the exterior
 *        function to return err_code if the err_code is not @ref NRF_SUCCESS.
 *
 * @param[in] err_code The error code to check.
 */
#ifdef DISABLE_PARAM_CHECK
#define VERIFY_SUCCESS()
#else
#define VERIFY_SUCCESS(err_code) VERIFY_TRUE((err_code) == NRF_SUCCESS, (err_code))
#endif /* DISABLE_PARAM_CHECK */

/**@brief Macro for calling error handler function if supplied error code any other than NRF_SUCCESS.
 *
 * @param[in] ERR_CODE Error code supplied to the error handler.
 */
#define APP_ERROR_CHECK(ERR_CODE)                           \
    do                                                      \
    {                                                       \
        const uint32_t LOCAL_ERR_CODE = (ERR_CODE);         \
        if (LOCAL_ERR_CODE != NRF_SUCCESS)                  \
        {                                                   \
            APP_ERROR_HANDLER(LOCAL_ERR_CODE);              \
        }                                                   \
    } while (0)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see from the above snippet, &lt;code&gt;VERIFY_SUCCESS()&lt;/code&gt; macro will verify that err_code is equal to &lt;code&gt;NRF_SUCCESS&lt;/code&gt;. If this statement is not true, it will return the error code. This is usefull if you want a function call to stop executing and returning the error code if an error have occurred.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;APP_ERROR_CHECK()&lt;/code&gt; will call the error handler if the given &lt;code&gt;err_code&lt;/code&gt; is not &lt;code&gt;NRF_SUCCESS&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>