2017 © Pedro Peláez
 

library exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

image

granam/exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  • Sunday, February 19, 2017
  • by jaroslavtyc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3,097 Installations
  • PHP
  • 57 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 21 Versions
  • 26 % Grown

The README.md

Test Coverage License, (*1)

Philosophy of exception hierarchy is kind of you need to know., (*2)

It is important to know what happened. And it happens..., (*3)

The system fails. Something exceptionable occurs., (*4)

Take extra care to get as much description of a problem as possible., (*5)

The good way how to achieve that is keep exceptions hierarchy clean and clear., (*6)

  • follow the project structure.
  • make a root exception marker as an interface.
  • include this interface in every exception you produce.
    • by that, anyone can catch exceptions from your project in his project, by a single catch
  • learn the difference between logic and runtime exception
    • the base distinction is the logic exception can be detected at compile time (for easy example by IDE), the runtime exception can not - it can occurs only in some combination of data and environment
    • logic exception should occurs if definitely there is an mistake in use of the application
      • that exception tells you: you are using something bad, fix it
    • runtime exception is everything else of course
      • that means: your application is not so robust as should be - fix it or ignore for eternity
    • is it so simple, with clean borders?
      • of course not
      • but like that you can catch all the logic exceptions into folder PersistentBugs and runtime ones into BulletproofFailures

In short

Runtime exception should occurs if something is wrong from outside., (*7)

Logic exception should occurs if something is wrong from inside., (*8)

Example of use of Logic and Runtime exception

You built an e-shop with an API., (*9)

Your frontend application sends to the API a request for new customer:, (*10)

  • email: dontbotherme

That is not valid email for sure. The frontend check failed and now you are forced to handle that failure., (*11)

So lets throw some Runtime (like InvalidEmailFormat) exception somewhere inside your code., (*12)

Your API of course should catch such exception and returns 400 Bad Request (and descriptive error message)., (*13)

In another case your application calculates price of an purchase, including discount coupon, volume discount, loyalty discount and... voala, the final price is negative!, (*14)

That is fatal error for sure, originating inside your application. Logic exception (like FinalPriceZeroOrLesser) should be thrown., (*15)

The API of course catch that exception and turn it into response 500 Server error (and log that exception for asap fix!) ., (*16)

The Versions

19/02 2017

4.0.x-dev

4.0.9999999.9999999-dev https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

php exception logic hierarchy runtime

19/02 2017

4.0.2

4.0.2.0 https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

php exception logic hierarchy runtime

19/02 2017

dev-master

9999999-dev https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

php exception logic hierarchy runtime

19/02 2017

4.0.1

4.0.1.0 https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

php exception logic hierarchy runtime

16/02 2017

4.0.0

4.0.0.0 https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

php exception logic hierarchy runtime

15/02 2017

3.0.x-dev

3.0.9999999.9999999-dev https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

php exception logic hierarchy runtime

15/02 2017

3.0.1

3.0.1.0 https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

php exception logic hierarchy runtime

15/02 2017

3.0.0

3.0.0.0 https://github.com/jaroslavtyc/granam-exceptions-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.6

 

The Development Requires

php exception logic hierarchy runtime

16/09 2015

2.3.x-dev

2.3.9999999.9999999-dev https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

16/09 2015

2.3.0

2.3.0.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

07/09 2015

2.2.x-dev

2.2.9999999.9999999-dev https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

07/09 2015

2.2.1

2.2.1.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

07/09 2015

2.2.0

2.2.0.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

02/09 2015

2.1.x-dev

2.1.9999999.9999999-dev https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

02/09 2015

2.1.1

2.1.1.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

01/09 2015

2.1.0

2.1.0.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

24/08 2015

2.0.0

2.0.0.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

21/07 2015

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

21/07 2015

1.0.2

1.0.2.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

12/05 2015

1.0.1

1.0.1.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime

29/03 2015

1.0.0

1.0.0.0 https://github.com/jaroslavtyc/granam-exception-hierarchy

The hierarchy skeleton of exceptions in a project

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

php exception logic hierarchy runtime