1'use strict'; 2 3const ErrorReportingMixinBase = require('./mixin-base'); 4const PositionTrackingPreprocessorMixin = require('../position-tracking/preprocessor-mixin'); 5const Mixin = require('../../utils/mixin'); 6 7class ErrorReportingPreprocessorMixin extends ErrorReportingMixinBase { 8 constructor(preprocessor, opts) { 9 super(preprocessor, opts); 10 11 this.posTracker = Mixin.install(preprocessor, PositionTrackingPreprocessorMixin); 12 this.lastErrOffset = -1; 13 } 14 15 _reportError(code) { 16 //NOTE: avoid reporting error twice on advance/retreat 17 if (this.lastErrOffset !== this.posTracker.offset) { 18 this.lastErrOffset = this.posTracker.offset; 19 super._reportError(code); 20 } 21 } 22} 23 24module.exports = ErrorReportingPreprocessorMixin; 25