# throw

Fiber::throw

Resumes execution of the fiber with an exception

# 

ENTITY

<div data-wrapper="1" role="Fiber">

public

</div>

<div data-wrapper="1" role="Fiber">

mixed

</div>

<div data-wrapper="1" role="Fiber">

Fiber::throw

</div>

<div data-wrapper="1" role="Fiber">

Throwable

</div>

<div data-wrapper="1" role="Fiber">

exception

</div>

Resumes the fiber by throwing the given exception from the current Fiber::suspend call.

If the fiber is not suspended when this method is called, a FiberError will be thrown.

# 

ENTITY

`exception`  
The exception to throw into the fiber from the current Fiber::suspend call.

# 

ENTITY

The value provided to the next call to Fiber::suspend or ENTITY if the fiber returns. If the fiber throws an exception before suspending, it will be thrown from the call to this method.

# 

ENTITY

<div class="informalexample">

```
<?php

$fiber = new Fiber(function () {
   try {
       // Suspend execution of the fiber declaring an interruption point
       Fiber::suspend();
   } catch (Throwable $e) {
       echo $e->getMessage();
   }
});

$fiber->start();

// Resumes execution of the fiber with
// passing the Exception to throw at the interruption point
$fiber->throw(new Exception('Message of an exception thrown at the current interrupt point'));

?>

   
```

ENTITY

    Message of an exception thrown at the current interrupt point

       

</div>