summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2009-10-19 23:48:56 +0200
committerFlorian Frank <flori@ping.de>2009-10-19 23:48:56 +0200
commitf5ff4bdc724a85516e50d6439bfd08ed71608953 (patch)
tree5de4205c8f459442751ca24ae1ab98961714184d
parenta6eff774542df29892b6bd7e6b08d93322f9055d (diff)
downloadjson-f5ff4bdc724a85516e50d6439bfd08ed71608953.tar.gz
nicer error messages
-rw-r--r--ext/json/ext/generator/unicode.c6
-rw-r--r--ext/json/ext/parser/unicode.c4
2 files changed, 5 insertions, 5 deletions
diff --git a/ext/json/ext/generator/unicode.c b/ext/json/ext/generator/unicode.c
index 93e8502..3ddfbe0 100644
--- a/ext/json/ext/generator/unicode.c
+++ b/ext/json/ext/generator/unicode.c
@@ -113,7 +113,7 @@ void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags
}
if (!isLegalUTF8(source, extraBytesToRead+1)) {
rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed");
+ "source sequence is illegal/malformed utf-8");
}
/*
* The cases all fall through. See "Note A" below.
@@ -134,7 +134,7 @@ void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags
if (flags == strictConversion) {
source -= (extraBytesToRead+1); /* return to the illegal value itself */
rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed");
+ "source sequence is illegal/malformed utf-8");
} else {
unicode_escape(buffer, UNI_REPLACEMENT_CHAR);
}
@@ -166,7 +166,7 @@ void JSON_convert_UTF8_to_JSON(VALUE buffer, VALUE string, ConversionFlags flags
if (flags == strictConversion) {
source -= (extraBytesToRead+1); /* return to the start */
rb_raise(rb_path2class("JSON::GeneratorError"),
- "source sequence is illegal/malformed");
+ "source sequence is illegal/malformed utf8");
} else {
unicode_escape(buffer, UNI_REPLACEMENT_CHAR);
}
diff --git a/ext/json/ext/parser/unicode.c b/ext/json/ext/parser/unicode.c
index 80e5c6f..6bd29e2 100644
--- a/ext/json/ext/parser/unicode.c
+++ b/ext/json/ext/parser/unicode.c
@@ -105,7 +105,7 @@ char *JSON_convert_UTF16_to_UTF8 (
} else if (flags == strictConversion) { /* it's an unpaired high surrogate */
ruby_xfree(tmp);
rb_raise(rb_path2class("JSON::ParserError"),
- "source sequence is illegal/malformed near %s", source);
+ "\\uXXXX is illegal/malformed utf-16 near %s", source);
}
} else { /* We don't have the 16 bits following the high surrogate. */
ruby_xfree(tmp);
@@ -118,7 +118,7 @@ char *JSON_convert_UTF16_to_UTF8 (
if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
ruby_xfree(tmp);
rb_raise(rb_path2class("JSON::ParserError"),
- "source sequence is illegal/malformed near %s", source);
+ "\\uXXXX is illegal/malformed utf-16 near %s", source);
}
}
/* Figure out how many bytes the result will require */