[ic] [interchange] Add better messages, support for application/json handling

Charles DeRykus derykus at gmail.com
Wed Dec 31 07:31:12 UTC 2014


> You don't have to test for $@ if you put the our $Has_JSON = 1 in the
> eval block like so:
>
> our $Has_JSON;
> eval {
>     require JSON;
>     $Has_JSON = 1;
> };
>
> if (!$Has_JSON) {
>     # ... error here (see below)?
> }

>>  6 of one, 1/2 dozen of the other.

Not to get too wonky but there are several subtle issues with $@ and block eval
tests. See the Try::Tiny docs.  None may be terribly relevant here but
if a block eval
is  used,  explicitly  setting $Has_JSON  just before terminating the
block is generally viewed as the safer practice.

-- 
Charles DeRykus



More information about the interchange-users mailing list