Skip to content
This repository has been archived by the owner on Jan 2, 2019. It is now read-only.

PHPExcel_Exception exists as class but is never used #78

Closed
dbonsch opened this issue Nov 16, 2012 · 11 comments
Closed

PHPExcel_Exception exists as class but is never used #78

dbonsch opened this issue Nov 16, 2012 · 11 comments

Comments

@dbonsch
Copy link
Member

dbonsch commented Nov 16, 2012

You have a custom Exception PHPExcel_Exception, but all classes still use the Exception class.

As PHPExcel_Exception extends Exception it would not break existing code if you just replace all "Exception"s with PHPExcel_Exception.

Sometimes it's a little annoying not to be able to differentiate between a PHPExcel_Exception and other Exceptions.

@MarkBaker
Copy link
Member

Currently, work is underway to replace all thrown Exceptions with PHPExcel specific Exception classes. This is a work in progress, but most of the readers and writers throw PHPExcel_Reader_Exception and PHPExcel_Writer_Exception already.

@dbonsch
Copy link
Member Author

dbonsch commented Nov 18, 2012

Happy to hear about that.
Can i help?

@MarkBaker
Copy link
Member

More than happy to accept offers of help.... it's as simple as wading through the code replacing every thrown Exception so that it throws the appropriate PHPExcel_xxx_Exception. I believe I've done the Reader and Writer Exceptions, and the Calc Engine has its own PHPExcel_Calculation_Exception, so all other thrown Exceptions should be PHPExcel_Exception. There's a few places in the code where Exceptions are caught, but these can largely be left simply catching Exception

@dbonsch
Copy link
Member Author

dbonsch commented Nov 18, 2012

Perfect. I'll take care of that and implement a clean Exception architecture.
I think i've also found some methods that claim to throw an Exception without calling any method or having a throw statement in the method body. ( I need to check if they not call some hidden "magic" methods )
I'm going to clean the apidoc too.

@MarkBaker
Copy link
Member

Yes, the APIDocs have got a bit out of date in places, and that's also a case of simply trawling through the code to fix all the docblocks, but it's a long, drawn-out chore checking every method that's called by a method to see if an Exception is thrown somewhere down the call stack

dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
…ception to

be able to catch all PHPExcel specific Exceptions in one block
@dbonsch
Copy link
Member Author

dbonsch commented Nov 19, 2012

I've changed the inheritance of the PHPExcel_*_Exception Exceptions, they now all extend from PHPExcel_Exception. Now we can fetch PHPExcel_Exception instead of the base Exception.
That's better if somebody want to catch PHPExcel specific Exceptions in his own code.

dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
@dbonsch
Copy link
Member Author

dbonsch commented Nov 19, 2012

Why are there Exceptions thrown in a catch bock of an Exceptions? Example: https://gist.github.com/4112606

dbonsch pushed a commit to dbonsch/PHPExcel that referenced this issue Nov 19, 2012
@MarkBaker
Copy link
Member

Thanks for all these Exception management changes.... I've had to merge them manually, unfortunately; but I just need to check for completeness and consistency (especially those in PHPExcel_Shared_*) and I should be in a position to commit them all tonight

@dbonsch
Copy link
Member Author

dbonsch commented Jan 14, 2013

Your're welcome.

I think i replaced all PHPExcel Exceptions. All the Exceptions inherit from a Base PHPExcel_Exception so users are able to catch just PHPExcel Exceptions. They should not need to catch a Graph, Writer or whatever Exception explicit.
They could, but they should not need to specify the type. For most cases just catching the PHPExcel_Exception will be good enough.

I did not yet run the tests, but if've tested it in my Tool/FW and it was running without errors.

Originally i planned to extend the tests and merge them in the actual head, but because i changed so many files that i got constantly new conflicts and stopped trying. ( I got an idea how sisyphos must have felt )

Maybe i should have done it in smaller pieces and send several pull requests. I'm lacking the experience how to interact with "non continuous integration models".
I'm used to commit directly in team repos and merge instantly.

I have several proposal for architecture improvements.
What would be the best way to participate without creating much effort on your side for the integration?
Should i just create a feature branch for every "proposal", and send a merge request?

@MarkBaker
Copy link
Member

Sorry, didn't manage to get the merge done tonight - too many interventions, so I didn't get my own final testing complete.

A full CI environment would be greate, and we use Travis, but don't yet have a comprehensive set of tests for significant portions of the code, and many of the tests we do have don't yet run cleanly.... it's a work in progress.

If you're interested in joining the development team, we can always use fresh blood. There's times when the mind gets too close minded with regard to the existing architecture after working on it for so long. And I'm busy with two large tasks at the moment (the switch from SimpleXML to XMLReader, and a complete rewrite of the calculation engine) so there's a lot of areas being neglected while my focus is on those.
Drop me a line if you want to join the team.

@dbonsch
Copy link
Member Author

dbonsch commented Jan 15, 2013

Done

@Progi1984 Progi1984 added this to the 1.8.0 milestone Aug 14, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants