On Thu Mar 25 11:09:29 2010, marc@questright.com wrote:
Show quoted text> You should be able to catch the error in an eval block. (I prefer
> Try::Tiny for that):
>
> use Try::Tiny;
>
> my $status = ...;
> try {
> $myString =~ s/\R/ /g;
> }
> catch {
> warn "Error on status $status->{id}: $_\n";
> };
>
> Something like that should report the status in which the error occurs
> and we can investigate.
>
> This is probably not a Net::Twitter bug (unless Net::Twitter is
> returning something different than Twitter is sending it), but I'll
> keep
> it open until we know.
>
> -Marc
Hi Marc,
I was able to catch the error in the way you suggested (thanks for tip).
Here is the error (actually two errors, but possibly with the same root
cause):
Error on status 11396609263: Malformed UTF-8 character (fatal) at
./myScript.pl line 344.
"\x{ffff}" does not map to utf8 at ./myScript.pl line 370.
Line 344 is as follows (mentioned previously):
$myString =~ s/\R/ /g;
And line 370 is just a print command for the same string:
print FH "$myString";
Just in case it's relevant, FH is opened for writing at the beginning of
the script in the following way:
open(DATA, '>>:encoding(UTF-8)', $dataFile) or die $!;
Here's a link to the relevant Tweet via the Twitter website:
http://twitter.com/SunMiHoRa/statuses/11396609263
Save for the fact that I can't read Chinese, I don't see anything
strange there. But perhaps that's just because the "\x{ffff}" is
non-printable?
In any case, it turns out that the script handles the error in more the
way I want it to when I use the try...catch block (i.e., it doesn't crap
out). Thus, I think I'm actually in good shape, now. But I would be
interested to know if you determine the source of the issue I am
experiencing--i.e., whether the source is Twitter itself allowing in
strange characters, Net::Twitter adding or modifying characters, or some
combination of the two. I would suspect the former, were it not for the
fact that the post shows up without issue on the web. But I also have
trouble imagining Net::Twitter would be introducing any of these strange
characters. So I'm a bit confused, but ultimately not too worried.
-Joe