1+ import { ErrorHandler } from '@angular/core' ;
12import {
23 Action ,
34 ActionReducer ,
@@ -56,7 +57,8 @@ function computeNextEntry(
5657 reducer : ActionReducer < any , any > ,
5758 action : Action ,
5859 state : any ,
59- error : any
60+ error : any ,
61+ errorHandler : ErrorHandler
6062) {
6163 if ( error ) {
6264 return {
@@ -71,7 +73,7 @@ function computeNextEntry(
7173 nextState = reducer ( state , action ) ;
7274 } catch ( err ) {
7375 nextError = err . toString ( ) ;
74- console . error ( err . stack || err ) ;
76+ errorHandler . handleError ( err . stack || err ) ;
7577 }
7678
7779 return {
@@ -90,7 +92,8 @@ function recomputeStates(
9092 committedState : any ,
9193 actionsById : LiftedActions ,
9294 stagedActionIds : number [ ] ,
93- skippedActionIds : number [ ]
95+ skippedActionIds : number [ ] ,
96+ errorHandler : ErrorHandler
9497) {
9598 // Optimization: exit early and return the same reference
9699 // if we know nothing could have changed.
@@ -113,7 +116,13 @@ function recomputeStates(
113116 const shouldSkip = skippedActionIds . indexOf ( actionId ) > - 1 ;
114117 const entry : ComputedState = shouldSkip
115118 ? previousEntry
116- : computeNextEntry ( reducer , action , previousState , previousError ) ;
119+ : computeNextEntry (
120+ reducer ,
121+ action ,
122+ previousState ,
123+ previousError ,
124+ errorHandler
125+ ) ;
117126
118127 nextComputedStates . push ( entry ) ;
119128 }
@@ -143,6 +152,7 @@ export function liftInitialState(
143152export function liftReducerWith (
144153 initialCommittedState : any ,
145154 initialLiftedState : LiftedState ,
155+ errorHandler : ErrorHandler ,
146156 monitorReducer ?: any ,
147157 options : Partial < StoreDevtoolsConfig > = { }
148158) {
@@ -337,7 +347,8 @@ export function liftReducerWith(
337347 committedState ,
338348 actionsById ,
339349 stagedActionIds ,
340- skippedActionIds
350+ skippedActionIds ,
351+ errorHandler
341352 ) ;
342353
343354 commitExcessActions ( stagedActionIds . length - options . maxAge ) ;
@@ -365,7 +376,8 @@ export function liftReducerWith(
365376 committedState ,
366377 actionsById ,
367378 stagedActionIds ,
368- skippedActionIds
379+ skippedActionIds ,
380+ errorHandler
369381 ) ;
370382
371383 commitExcessActions ( stagedActionIds . length - options . maxAge ) ;
@@ -393,7 +405,8 @@ export function liftReducerWith(
393405 committedState ,
394406 actionsById ,
395407 stagedActionIds ,
396- skippedActionIds
408+ skippedActionIds ,
409+ errorHandler
397410 ) ;
398411
399412 // Recompute state history with latest reducer and update action
@@ -429,7 +442,8 @@ export function liftReducerWith(
429442 committedState ,
430443 actionsById ,
431444 stagedActionIds ,
432- skippedActionIds
445+ skippedActionIds ,
446+ errorHandler
433447 ) ;
434448 monitorState = monitorReducer ( monitorState , liftedAction ) ;
435449
0 commit comments