php - Throwing exceptions for error results in consumed APIs -


do write specific exceptions error responses of apis use?

e.g.:

class smsserviceexception extends exception {  }  class smsservicesendexception extends smsserviceexception {  } 

is there specific built in exception in php situation? there 1 invalid arguments invalidargumentexception.

you're go when comes exception. php has native exceptions these not refer non-built-in php problem.

it quite common mistake miss argument, throw exception php needs when doing own things, creating classes can freely create exceptions since many of ideas not have default exception in php.

you on other hand write exception class entire api , pass in name of module edit exception creating 1 "flexible" exception. make abit less readable code tho keep in mind ;)


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -