Giter Site home page Giter Site logo

exception handling about opentok-php-sdk HOT 4 CLOSED

opentok avatar opentok commented on July 19, 2024
exception handling

from opentok-php-sdk.

Comments (4)

aoberoi avatar aoberoi commented on July 19, 2024

after some conversation with the team, it looks like the important points are the following:

  • allow developers to catch errors that are actionable. this class of errors is a Runtime. contrast this with Logic errors
  • i.e. an archive cannot be started because there is nobody connected to the session – a developer can retry.
  • allow developers to group errors by dependency/feature
  • i.e. each error we throw should be an OpenTokError. All archiving errors can be ArchivingErrors that inherit from OpenTokErrors.

from opentok-php-sdk.

aoberoi avatar aoberoi commented on July 19, 2024

found a pretty good article that discusses best practices in PHP: http://ralphschindler.com/2010/09/15/exception-best-practices-in-php-5-3

According to this article, here is a proposed design for exceptions in the SDK:

  • OpenTok\Exception - an interface that serves as a way for consumers to catch package level exceptions. all other exceptions will implement this interface
  • OpenTok\ArchiveException - an interface that serves as a way for consumer to catch Archiving component level exceptions. all exceptions that are a result of an archiving operation will implement this interface
  • OpenTok\InvalidArgumentException extends \InvalidArgumentException - our own subclass of the system provided exception class so we can implement the interfaces we need to encapsulate.
  • OpenTok\UnexpectedValueException extends \UnexpectedValueException - similar reasoning as above - used for generic server response errors that are aren't described elsewhere.
  • OpenTok\DomainException extends \DomainException - similar reasoning as above
  • OpenTok\AuthenticationException extends OpenTok\DomainException - 401's and such.
  • OpenTok\ArchiveAuthenticationException extends OpenTok\AuthenticationException - same as above but implements the OpenTok\ArchiveException interface.
  • OpenTok\ArchiveDomainException extends OpenTok\DomainException - adds implementation of OpenTok\ArchiveException. - used for almost all other 4xx response codes because they are mostly logic issue driven.
  • OpenTok\ArchiveUnexpectedValueException extends OpenTok\UnexpectedValueException - adds implementation of OpenTok\ArchiveException interface. - used for archiving 5xx response codes.

from opentok-php-sdk.

aoberoi avatar aoberoi commented on July 19, 2024

this needs test coverage still

from opentok-php-sdk.

aoberoi avatar aoberoi commented on July 19, 2024

going to call this one fixed and open a new issue for the test coverage.

from opentok-php-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.