elabx Posted May 25, 2018 Share Posted May 25, 2018 Hi! I'm working on a module, and doing some Ajax operations, for example, I am creating some fields and doing this while checking if field already exists: if($fieldExists){ throw new WireException('Field already exists with that name. Please choose another name'); }else{ ... } In the response, I'm heading a 200 response code and the following code: {"error":true,"message":"Field already exists with that name. Please choose another name"} Is there a way I could customize that error message? if($fieldExists){ throw new WireException(array("message" => "...", "existingFieldId" => 1)); }else{ ... } And expect the response to have the custom info I want? I'm very intrigued on how the exception ends up as a json object in the resopnse. Thanks for further answers! Link to comment Share on other sites More sharing options...
Zeka Posted May 25, 2018 Share Posted May 25, 2018 https://processwire.com/apigen/class-Exception.html#___construct Example https://github.com/processwire/processwire/blob/48fe0769a4eb3d0f5b4732fd01b4b4ed8262d952/wire/core/Fields.php#L165 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now