@@ -181,12 +181,13 @@ func WithEventHandler(handler func(e *Event)) Option {
181
181
}
182
182
183
183
// WithStagePanicHandler sets a panic handler for the stages within a pipeline.
184
- // When a stage within the pipeline panics, the provided handler will be invoked, enabling
185
- // clients to capture the panic, such as for observability purposes .
184
+ // When a pipeline stage panics, the provided handler will be invoked, allowing
185
+ // the client to handle the panic in whatever way they see fit .
186
186
//
187
187
// Note:
188
- // - The client is responsible for deciding whether to recover from the panic or propagate it further.
189
- // - Currently, only the Function stage supports this functionality.
188
+ // - Only the Function stage supports this functionality.
189
+ // - The client is responsible for deciding whether to recover from the panic or panicking again.
190
+ // - If a panic handler is not set, the panic will be propagated normally.
190
191
func WithStagePanicHandler (ph StagePanicHandler ) Option {
191
192
return func (p * Pipeline ) {
192
193
p .panicHandler = ph
@@ -279,10 +280,8 @@ func (p *Pipeline) Start(ctx context.Context) error {
279
280
}
280
281
281
282
for i , s := range p .stages {
282
- if p .panicHandler != nil {
283
- if phs , ok := s .(StagePanicHandlerAware ); ok {
284
- phs .SetPanicHandler (p .panicHandler )
285
- }
283
+ if phs , ok := s .(StagePanicHandlerAware ); ok && p .panicHandler != nil {
284
+ phs .SetPanicHandler (p .panicHandler )
286
285
}
287
286
288
287
var err error
0 commit comments