# Throwing exception in future callback

**URL:** <https://discuss.akka.io/t/throwing-exception-in-future-callback/6459>\
**Category:** Akka Libraries\
**Tags:** akka\
**Created:** [May 9, 2020, 4:55pm UTC](https://discuss.akka.io/t/throwing-exception-in-future-callback/6459 "2020-05-09T16:55:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhshah290](https://avatars.discourse-cdn.com/v4/letter/h/2acd7d/32.png) [@hhshah290](https://discuss.akka.io/u/hhshah290)\
**Post date:** [May 9, 2020, 4:55pm UTC](https://discuss.akka.io/t/throwing-exception-in-future-callback/6459/1 "2020-05-09T16:55:18Z")

</div>

Does throwing an exception in a Future callback result in the Actor’s suspension (the actor in which the future callback code is). Just want to make sure because technically that code is not necessarily being executed by the main message processing thread and I don’t know if there would be a semantic difference? Thanks for any help!

---

<div class="post-metadata">

**Author:** ![johanandren](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/johanandren/32/85_2.png) [@johanandren](https://discuss.akka.io/u/johanandren)\
**Post date:** [May 11, 2020, 8:07am UTC](https://discuss.akka.io/t/throwing-exception-in-future-callback/6459/2 "2020-05-11T08:07:47Z")

</div>

Future callback code is not executing in the actor, it will be running on the (implicit) execution context you passed when defining it.

You should be **really** careful with future callbacks in actors, it is very easy to touch internal mutable state by mistake.

Best is not mixing them at all and instead use `pipeTo` to send the future result to the actor as a message and react on that message, if you can’t do that it is good to move such callback logic to a static method outside of the actor so that it cannot close over actor internals.
