diff --git a/aio/transforms/examples-package/services/region-parser.js b/aio/transforms/examples-package/services/region-parser.js index 4f144150a9..49a579af3d 100644 --- a/aio/transforms/examples-package/services/region-parser.js +++ b/aio/transforms/examples-package/services/region-parser.js @@ -114,7 +114,8 @@ function removeLast(array, item) { array.splice(index, 1); } -function RegionParserError(message, lineNum) { +function RegionParserError(message, index) { + const lineNum = index + 1; this.message = `regionParser: ${message} (at line ${lineNum}).`; this.lineNum = lineNum; this.stack = (new Error()).stack; diff --git a/aio/transforms/examples-package/services/region-parser.spec.js b/aio/transforms/examples-package/services/region-parser.spec.js index a0e3fc34ca..56141e7bef 100644 --- a/aio/transforms/examples-package/services/region-parser.spec.js +++ b/aio/transforms/examples-package/services/region-parser.spec.js @@ -96,24 +96,24 @@ describe('regionParser service', () => { it('should error if we attempt to open an already open region', () => { expect(() => regionParser(t('/* #docregion */', 'abc', '/* #docregion */', 'def'), 'test-type')) .toThrowError( - 'regionParser: Tried to open a region, named "", that is already open (at line 2).'); + 'regionParser: Tried to open a region, named "", that is already open (at line 3).'); expect( () => regionParser(t('/* #docregion X */', 'abc', '/* #docregion X */', 'def'), 'test-type')) .toThrowError( - 'regionParser: Tried to open a region, named "X", that is already open (at line 2).'); + 'regionParser: Tried to open a region, named "X", that is already open (at line 3).'); }); it('should error if we attempt to close an already closed region', () => { expect(() => regionParser(t('abc', '/* #enddocregion */', 'def'), 'test-type')) - .toThrowError('regionParser: Tried to close a region when none are open (at line 1).'); + .toThrowError('regionParser: Tried to close a region when none are open (at line 2).'); expect( () => regionParser(t('/* #docregion */', 'abc', '/* #enddocregion X */', 'def'), 'test-type')) .toThrowError( - 'regionParser: Tried to close a region, named "X", that is not open (at line 2).'); + 'regionParser: Tried to close a region, named "X", that is not open (at line 3).'); }); it('should handle whitespace in region names on single annotation', () => {