Skip to content

Exceptions

pierr edited this page Nov 21, 2014 · 7 revisions

Exception

All exeptions are available in th object : Fmk.Helpers.Exceptions or Focus.Helpers.Exceptions See file

  • ** ArgumentNullException ** => To use when a propery is null and shouldn't be
  • ** ArgumentInvalidException ** => To use when a propery is not null but has the wrong value or the wrong type.
  • ** NotImplementedException ** => To use when a function is not implemented
  • ** DependencyException ** => To use when a dependency is missing

They all have a similar signature. Exception(message, context)

var ArgumentInvalidException =  Fmk.Helpers.Exceptions.ArgumentInvalidException;
function saveObject(jsonObject){
  if(!_.isObject(jsonObject)){
     throw new ArgumentInvalidException(
                 "jsonObject should be an object",
                 jsonObject
               );
  }
}

Really often these Exceptions should be use after testing properties with underscore. All types has a function associated:

Candidates for all these type checking are the services. Each parameter of a service should be tested.

Clone this wiki locally