Path

ez projects / ezjscore / forum / general / how to feed data.error_text


How to feed data.error_text

You need to be logged in to post messages in the forums. New users may register here.

Matthieu Sévère

Member since:
11 October 2012

Posts: 34

Wednesday 14 April 2010 9:40:05 pm

Hello André,

Is that possible to provide an example of how to feed the data.error_text variable in a php server call ?

Thanks

--
eZ certified developer: http://ez.no/certification/verify/346216

Up

André R

Member since:
20 August 2005

Posts: 171

Saturday 17 April 2010 12:57:21 pm

From 1.1 and up (thanks to xrow) you can use exceptions, call code:



       $response = array( 'error_text' => '', 'content' => '' );


       if( $call instanceOf ezjscServerRouter )


       {


           try


           {


               $response['content'] = $call->call();


           }


           catch ( Exception $e )


           {


               $response['error_text'] = $e->getMessage();


           }


       }


       else


       {


           $response['error_text'] = 'Not a valid ezjscServerRouter argument: "' . $call . '"';


       }


       $r[] = ezjscAjaxContent::autoEncode( $response, $contentType );




Suggestions on how to further enhance this is welcome, for instance add an error_type that is '' if ok, and exception class on exception?
But ideally, should use http status codes more, but that would be a bc break, so will have to wait for "2.0".

--
ar

Up

You need to be logged in to post messages in the forums. New users may register here.