Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Commit

Permalink
error: new error CSV_MAX_RECORD_SIZE code
Browse files Browse the repository at this point in the history
  • Loading branch information
wdavidw committed Oct 19, 2019
1 parent 6704eab commit abc889b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,14 @@ class Parser extends Transform {
}
if(this.state.commenting === false){
if(max_record_size !== 0 && this.state.record_length + this.state.field.length > max_record_size){
const err = this.__error(`Max Record Size: record exceed the maximum number of tolerated bytes of ${max_record_size} on line ${this.info.lines}`)
const err = this.__error(
new CsvError('CSV_MAX_RECORD_SIZE', [
'Max Record Size:',
'record exceed the maximum number of tolerated bytes',
`of ${max_record_size}`,
`on line ${this.info.lines}`,
], this.__context())
)
if(err !== undefined) return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('API Types', () => {

describe('Parser', () => {

it('Respect parse signature', () =>{
it('Respect parse signature', () => {
// No argument
parse()
parse("")
Expand Down
7 changes: 6 additions & 1 deletion test/option.max_record_size.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

parse = require '../lib'
assert_error = require './api.assert_error'

describe 'Option `max_record_size`', ->

Expand All @@ -23,5 +24,9 @@ describe 'Option `max_record_size`', ->
hi,xxxxxxxxxxxxxxx,jk
lm,no,pq
''', max_record_size: 10, (err) ->
err.message.should.eql 'Max Record Size: record exceed the maximum number of tolerated bytes of 10 on line 3'
assert_error err,
message: 'Max Record Size: record exceed the maximum number of tolerated bytes of 10 at line 3'
code: 'CSV_MAX_RECORD_SIZE'
column: 1, empty_lines: 0, header: false, index: 1, invalid_field_length: 0,
quoting: false, lines: 3, records: 2
next()

0 comments on commit abc889b

Please sign in to comment.