Skip to content

Commit 572c999

Browse files
authored
Merge pull request #470 from Shopify/remove-exception-line
Stop including the parser source __LINE__ in exceptions
2 parents 415953c + de9eb1d commit 572c999

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

ext/json/ext/generator/generator.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,10 @@ static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_St
997997
if (!allow_nan) {
998998
if (isinf(value)) {
999999
fbuffer_free(buffer);
1000-
rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
1000+
rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp));
10011001
} else if (isnan(value)) {
10021002
fbuffer_free(buffer);
1003-
rb_raise(eGeneratorError, "%u: %"PRIsVALUE" not allowed in JSON", __LINE__, RB_OBJ_STRING(tmp));
1003+
rb_raise(eGeneratorError, "%"PRIsVALUE" not allowed in JSON", RB_OBJ_STRING(tmp));
10041004
}
10051005
}
10061006
fbuffer_append_str(buffer, tmp);

ext/json/ext/parser/parser.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
948948

949949
{p = p - 1; } {p+= 1; cs = 29; goto _out;}
950950
} else {
951-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
951+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
952952
}
953953
}
954954
np = JSON_parse_float(json, p, pe, result);
@@ -990,7 +990,7 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
990990
if (json->allow_nan) {
991991
*result = CInfinity;
992992
} else {
993-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8);
993+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8);
994994
}
995995
}
996996

@@ -1002,7 +1002,7 @@ static char *JSON_parse_value(JSON_Parser *json, char *p, char *pe, VALUE *resul
10021002
if (json->allow_nan) {
10031003
*result = CNaN;
10041004
} else {
1005-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2);
1005+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2);
10061006
}
10071007
}
10081008

@@ -2348,7 +2348,7 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
23482348
if(cs >= JSON_array_first_final) {
23492349
return p + 1;
23502350
} else {
2351-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
2351+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
23522352
return NULL;
23532353
}
23542354
}
@@ -2413,7 +2413,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
24132413
}
24142414
rb_enc_raise(
24152415
EXC_ENCODING eParserError,
2416-
"%u: incomplete unicode character escape sequence at '%s'", __LINE__, p
2416+
"incomplete unicode character escape sequence at '%s'", p
24172417
);
24182418
} else {
24192419
UTF32 ch = unescape_unicode((unsigned char *) ++pe);
@@ -2426,7 +2426,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
24262426
}
24272427
rb_enc_raise(
24282428
EXC_ENCODING eParserError,
2429-
"%u: incomplete surrogate pair at '%s'", __LINE__, p
2429+
"incomplete surrogate pair at '%s'", p
24302430
);
24312431
}
24322432
if (pe[0] == '\\' && pe[1] == 'u') {
@@ -3225,7 +3225,7 @@ static VALUE cParser_parse(VALUE self)
32253225
if (cs >= JSON_first_final && p == pe) {
32263226
return result;
32273227
} else {
3228-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
3228+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
32293229
return Qnil;
32303230
}
32313231
}

ext/json/ext/parser/parser.rl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,14 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
222222
if (json->allow_nan) {
223223
*result = CNaN;
224224
} else {
225-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 2);
225+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 2);
226226
}
227227
}
228228
action parse_infinity {
229229
if (json->allow_nan) {
230230
*result = CInfinity;
231231
} else {
232-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p - 8);
232+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p - 8);
233233
}
234234
}
235235
action parse_string {
@@ -245,7 +245,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
245245
fexec p + 10;
246246
fhold; fbreak;
247247
} else {
248-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
248+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
249249
}
250250
}
251251
np = JSON_parse_float(json, fpc, pe, result);
@@ -447,7 +447,7 @@ static char *JSON_parse_array(JSON_Parser *json, char *p, char *pe, VALUE *resul
447447
if(cs >= JSON_array_first_final) {
448448
return p + 1;
449449
} else {
450-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
450+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
451451
return NULL;
452452
}
453453
}
@@ -512,7 +512,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
512512
}
513513
rb_enc_raise(
514514
EXC_ENCODING eParserError,
515-
"%u: incomplete unicode character escape sequence at '%s'", __LINE__, p
515+
"incomplete unicode character escape sequence at '%s'", p
516516
);
517517
} else {
518518
UTF32 ch = unescape_unicode((unsigned char *) ++pe);
@@ -525,7 +525,7 @@ static VALUE json_string_unescape(char *string, char *stringEnd, int intern, int
525525
}
526526
rb_enc_raise(
527527
EXC_ENCODING eParserError,
528-
"%u: incomplete surrogate pair at '%s'", __LINE__, p
528+
"incomplete surrogate pair at '%s'", p
529529
);
530530
}
531531
if (pe[0] == '\\' && pe[1] == 'u') {
@@ -864,7 +864,7 @@ static VALUE cParser_parse(VALUE self)
864864
if (cs >= JSON_first_final && p == pe) {
865865
return result;
866866
} else {
867-
rb_enc_raise(EXC_ENCODING eParserError, "%u: unexpected token at '%s'", __LINE__, p);
867+
rb_enc_raise(EXC_ENCODING eParserError, "unexpected token at '%s'", p);
868868
return Qnil;
869869
}
870870
}

0 commit comments

Comments
 (0)