Comments (12)
That's exactly what I was trying to say, precedence is the right word here (sorry for my english 😄).
from central.
I like the idea of have a normalized makdown template, related to error code.
But, in PHP world, we like to abuse of ClassName for Exception, instead of using detailed error code.
And i've commonly end up to use error code
as severity index, like E_NOTICE, E_USER_ERROR...
or any personal constant definition for this purpose.
Can you give us a detail about C
and D
class and how we deal with it in PHP ?
Does that mean each throw new Exception
must have code specified, or we will have ExceptionNotFound
call parent exception with the not found
code error spread ?
from central.
we like to abuse of ClassName for Exception, instead of using detailed error code.
It does not conflict. We can have nice exception types, and nice codes too. Exception types (sub-classes of Exception
) are useful for catch
block, and anything related to types, and the code is related to the information we can provide/link to this exception.
And i've commonly end up to use error code as severity index, like E_NOTICE, E_USER_ERROR...
or any personal constant definition for this purpose.
Hmm yes. I understand the need to have a severity attribute on exception, but I would not use E_*
constants. And I won't never use the code attribute to store this information neither.
Can you give us a detail about C and D class and how we deal with it in PHP ?
Simply indexing exceptions like 1, 2, 4 for C
, and 3, 5, 6, 7 for D
for instance. Just a big counter for the whole library.
Does that mean each
throw new Exception
must have code specified, or we will haveExceptionNotFound
call parent exception with the not found code error spread?
Good question. What happens if an exception has no code? Well, we won't tell the user to use hoa explain
to find more information. But if a previous exception has a code, then we can tell the user: “There is no code attached to this exception, but this exception is due to another one, and its has a code! Maybe hoa explain <thiscode>
can provide some information”. Thoughts?
from central.
It seems a good idea to use Exception hierarchy to retrieve the last valid code that can be explained. The source exception is often the source of the problem.
from central.
Be careful: We will not be able to use class hierarchy. If a class E extends Exception
has no code, then its parents will have no code either. However, my proposal is to use exception precedence (an exception “embedding” another exceptions).
from central.
Ok we are on same line, but, look at Hoa Exception today.
Gimme How many Exception have error code, versus total number of Exception.
This is why i'm asking, do we need to refactor our Exception by strictly specify a error code ?
as an example, if a method who throws an exception expects to receive an array of strings but receives a number instead, we should throw Exception($msg, $code)
instead of ArrayOfStringException()
.
Can we share code between library ?
the array of string example is pretty common.
from central.
@Pierozi for me the code can still use ArrayOfStringException()
but that exception must define its own error code. I think that updating the code to use a "basic" exception everywhere but with a code will be more complicated to understand.
from central.
The code is given in the exception constructor, as we always do:
throw new MyException($message, $code, $arguments, $previous);
from central.
Yesterday evening, we talked about this RFC during the Hoa Virtual meeting.
In Hoa, each exception already exists for a specific need and already have a solid meaning. Relying on exception types instead of creating code may be more relevant.
Now, with Kitab, we can add all the documentation above the class declaration with examples. This examples will be tested to be sure the documentation is always valid.
The hoa explain
must exists to help users retrieving exception details. We can use the class documentation as description and add more details inside command output (places where the exception can be thrown, solution suggestions, link to online resources...).
from central.
If you look at angular js 1, all error come with a link inside the js console to the website of angular. And the website of angular display an explanation on this error. For me like shulard say, Hoa is very specific in his exception, so just with the exception name we could redirect to a website with explanation, overall with kitab.
from central.
@shulard @Grummfy Actually, you're right and I think hoa explain
suddenly becomes useless. I quote you:
places where the exception can be thrown, solution suggestions, link to online resources…
All that stuff can be added directly into the documentation.
This is OK to cancel an RFC if we have a single tool that addresses several problems or needs. This is actually even better!
from central.
However, if people does not have Kitab installed or an Internet access, we can still have the hoa explain T
command to print explanations about the exception T
, i.e. to extract the documentation directly.
from central.
Related Issues (20)
- steps for next version - bc break HOT 7
- Drop PHP 5.x HOT 15
- Drop Hoa\Log HOT 6
- Configure mirror on Gitlab HOT 7
- no more gitter? HOT 7
- Configure Mirror on Pikacode HOT 9
- create repository for atoum-option-extension HOT 3
- Configure bors-ng for all projects HOT 2
- Move PR from Ruler to Central HOT 1
- Add rexfordkelly to contributors and contributors.md
- Remove synchronizing gitlab on bhoat HOT 1
- Dependency errors when installed with prefer-lowest HOT 1
- Add rodion-k to contributors and contributors.md
- Deprecate unused libraries HOT 20
- Removing Rush Release
- Add dependabot on libraries
- Add @jwage and @SilverFire as a new contributor HOT 1
- Add atefBB as contributor HOT 1
- Add @taylorotwell as a contributor
- Add @mikeshatch as a contributor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from central.