2020import ResultSummary from './result-summary' ;
2121import { EMPTY_CONNECTION_HOLDER } from './internal/connection-holder' ;
2222
23+ const DEFAULT_ON_ERROR = error => {
24+ console . log ( 'Uncaught error when processing result: ' + error ) ;
25+ } ;
26+ const DEFAULT_ON_COMPLETED = summary => {
27+ } ;
28+
2329/**
2430 * A stream of {@link Record} representing the result of a statement.
2531 * @access public
@@ -102,12 +108,12 @@ class Result {
102108 * @return
103109 */
104110 subscribe ( observer ) {
105- const onCompletedOriginal = observer . onCompleted ;
106111 const self = this ;
107- const onCompletedWrapper = ( metadata ) => {
108112
113+ const onCompletedOriginal = observer . onCompleted || DEFAULT_ON_COMPLETED ;
114+ const onCompletedWrapper = ( metadata ) => {
109115 const additionalMeta = self . _metaSupplier ( ) ;
110- for ( let key in additionalMeta ) {
116+ for ( let key in additionalMeta ) {
111117 if ( additionalMeta . hasOwnProperty ( key ) ) {
112118 metadata [ key ] = additionalMeta [ key ] ;
113119 }
@@ -122,10 +128,7 @@ class Result {
122128 } ;
123129 observer . onCompleted = onCompletedWrapper ;
124130
125- const onErrorOriginal = observer . onError || ( error => {
126- console . log ( "Uncaught error when processing result: " + error ) ;
127- } ) ;
128-
131+ const onErrorOriginal = observer . onError || DEFAULT_ON_ERROR ;
129132 const onErrorWrapper = error => {
130133 // notify connection holder that the used connection is not needed any more because error happened
131134 // and result can't bee consumed any further; call the original onError callback after that
0 commit comments