# Cfunction error handling

**URL:** <https://discourse.julialang.org/t/cfunction-error-handling/123925>\
**Category:** General Usage\
**Tags:** embedding, error\
**Created:** [December 17, 2024, 1:29pm UTC](https://discourse.julialang.org/t/cfunction-error-handling/123925 "2024-12-17T13:29:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergey](https://avatars.discourse-cdn.com/v4/letter/s/9fc348/32.png) [@Sergey](https://discourse.julialang.org/u/Sergey)\
**Post date:** [December 17, 2024, 1:29pm UTC](https://discourse.julialang.org/t/cfunction-error-handling/123925/1 "2024-12-17T13:29:55Z")

</div>

Hi.  
Im calling `cfunctions` from c++ code.  
Is it possible not to break execution and do error handling if one occure on julia sode?

for exmple:

```julia
function calc(x :: Float32)
   return 100 * sqrt(-x)
end 

```

call this with any positive x from c++ will totally crash.

`JL_TRY / JL_CATCH` will catch those, but i cant find out the way to print error message. ANd this macro works only once in a function.

Is there a correct way to handle cfunction errors from c++?
