Is the `ic_cdk::setup` function vestigial now?

There’s a function ic_cdk::setup that i noticed present in the init function when digging around in the Open Chat repo.

I checked with the brilliant @hpeebles regarding this and he explained to me that it’s for

seeing the error message in the response if a call panics

I have however noticed that I do get detailed panic messages in my responses without implementing this.

I wanted to check with @lwshang and @roman-kashitsyn if it’s considered best practice to call this method from the init method or if it’s unnecessary at this point.


1 Like

All ic_cdk::setup() does is call into setup_panic_hook.

This does 2 things whenever your code panics.

1 - it calls print, which means you can see the error message when running a local replica.
2 - it calls trap with the error message, this is what adds the error message to the response.

But it looks like you don’t need to explicitly call ic_cdk::setup() since it is included in the code generated by each of the cdk macros (see here).