CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Error handling in the api: suggestion for improvment
Pages: [1]

Author Topic: Error handling in the api: suggestion for improvment  (Read 675 times)

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Error handling in the api: suggestion for improvment
August 27, 2010, 05:56:39 am
Right now, and error is raised by:

civicrm_create_error( ts( 'Input parameters is not an array' ))

1) There isn't any "error code" that can be properly parsed
2) And as the error msg is translated, it can't be used reliably either to know what error we encountered


I would like to add a new param to civicrm_create_error ("msg","error_code"), and return it to the caller (eg. rest or ajax)

What do you think ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Error handling in the api: suggestion for improvment
August 27, 2010, 07:27:41 am


To make this effective, we'll need to:

1. Have a list of error codes, names and descriptions
2. Update that list (and potentially use that same list to generate a wiki document)
3. I think most systems which use error codes, get the description from a centralized place (db?) to avoid inconsistency
4. change the code to follow the standards across the entire API

so the project is a bit larger than just adding the error_code variable. wanna take this on for 3.3? note that freeze is schedule for end sept / early oct :)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Error handling in the api: suggestion for improvment
August 28, 2010, 02:08:28 am
Good idea Xavier! I agree with Lobo that it will require a bit of work. I think we need to create a table that holds the error codes, if necessary type of error (warning, fatal etc.) and an error message. Ideally this error message should be multi-lingual? But perhaps that part would be for a later point in time. Would it be a nice project for a sprint?
Erik
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Error handling in the api: suggestion for improvment

This forum was archived on 2017-11-26.