X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fmisc%2Fareacodes.cgi;h=afbe93e91bcdd257abad62c8660d6d490b7831c6;hp=9d32a3baf8fcda7f4850cd97e7c71c1443208e02;hb=ff27c3f36240aee48ed50153dd5d8fe3ac3f2443;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924 diff --git a/httemplate/misc/areacodes.cgi b/httemplate/misc/areacodes.cgi index 9d32a3baf..afbe93e91 100644 --- a/httemplate/misc/areacodes.cgi +++ b/httemplate/misc/areacodes.cgi @@ -1,4 +1,4 @@ -<% objToJson(\@areacodes) %> +<% encode_json({ error => $error, areacodes => \@areacodes}) %>\ <%init> my( $state, $svcpart ) = $cgi->param('arg'); @@ -7,6 +7,8 @@ my $part_svc = qsearchs('part_svc', { 'svcpart'=>$svcpart } ); die "unknown svcpart $svcpart" unless $part_svc; my @areacodes = (); +my $error; + if ( $state ) { my @exports = $part_svc->part_export_did; @@ -17,9 +19,12 @@ if ( $state ) { } my $export = $exports[0]; - my $something = $export->get_dids('state'=>$state); + local $@; + local $SIG{__DIE__}; + my $something = eval { $export->get_dids('state'=>$state) }; + $error = $@; - @areacodes = @{ $something }; + @areacodes = @{ $something } if $something; }