Replace Error.pm and try/catch blocks

Warning in Error.pm documentation:

WARNING

Using the "Error" module is no longer recommended due to the black-magical nature of its syntactic sugar, which often tends to break. Its maintainers have stopped actively writing code that uses it, and discourage people from doing so.

Issues experienced

it appears as though some of the recent issues with unit tests are due in part to nested try/catch blocks. Babar found that when Assert's are enabled in core, they take precedence over the try/catch blocks in the Unit Tests. In addition because Unit Tests run inside a try block, tests that use try blocks can have unpredictable results.

Functionality required

What functionality is required from Error.pm or it's replacement. What do we need in core, and in the Unit Test framework?

Discussion

(12:15:26 PM) gac410: Babar - I was trying to figure out Sven's change to ConfigureTests - and his Try / Except block - never did find the docs for Except.
(12:16:03 PM) gac410: But CPAN Error seems to say that development has stopped on Try/catch, and they recommend that it not be used due to issues in the magic.
(12:17:01 PM) gac410: "WARNING:  Using the "Error" module is no longer recommended due to the  black-magical nature of its syntactic sugar,  ..."
(12:18:17 PM) gac410: Wondering if that might be what is hurting try/except ...  for some reason the variables returned from the try block are uninitialized outside of the block even though they are declared outside of the block,  and are valid inside the block.
(12:20:08 PM) gac410: never mind about not finding except docs though - if I had read past the warning  ...,  :-(
...
(01:23:00 PM) Babar: did I tell you how to reproduce the crash with assert for configure?
(01:23:09 PM) Babar: you just enable assert, but in LocalLib.cfg
(01:23:23 PM) ***Babar has it enabled 'globally', like in his shell, and this passes
(01:23:32 PM) Babar: but if I enable them in LocalLib.cfg, it crashes
(01:23:41 PM) gac410: Yes I recall - it explains why my issues kept coming and going.
(01:23:46 PM) ***gac410 doesn't understand 
(01:24:39 PM) gac410: I also don't understand try/catch - that sometimes catches errors and sometimes doesn't -  added some asserts to Meta to find some issues and could never handle them - they always just bubbled up to a crash.
(01:25:28 PM) gac410: Suspect that that statement in CPAN Error docs about black-magical nature might be accurate  ;-)
(01:26:13 PM) Babar: yeah, Error.pm wasn't a good idea tbh :)
(01:26:19 PM) Babar: but it was the only one available at that time
(01:26:41 PM) gac410: I've been trying to get unit tests running on Windows after Sven's issues.   so got sidetracked from my Meta asserts and can't even remember why I was there tbh.
(01:27:54 PM) Babar: No data could be read from file at /usr/share/perl/5.10/Archive/Tar.pm line 1342
(01:27:58 PM) Babar: without ASSERT
(01:28:01 PM) Babar: but with them, it's...
(01:28:15 PM) Babar: Sven said he made them work on Windows
(01:28:43 PM) Babar: No such file or directory at UnitTestContrib/test/unit/FoswikiTestCase.pm line 138
(01:28:44 PM) gac410: I did try a try/catch around Tar - but couldn't catch the error and it broke more than it fixed, so I removed.
(01:28:48 PM) Babar: which is the call to the MANIFEST
(01:29:39 PM) Babar: *** No data could be read from file at /usr/share/perl/5.10/Archive/Tar.pm line 1342
(01:29:47 PM) Babar: is there, but it seems it's doing something else with ASSERT on
(01:30:00 PM) gac410: Thing is, that the functions appear to work for live installs,    Unit test fail, but wondering if it's a test issue instead
(01:31:40 PM) gac410: I need to go back and spend a couple of hours recreating and debugging - I don't understand issues so patches are just cut/try/shotgun  which is not exactly productive.
(01:33:29 PM) Babar: calling Unit::TestRunner::start Configure, which calls ... hum...
(01:33:33 PM) gac410: Maybe change the Archive code to use eval.    Sven also suggested moving to sandbox for all external calls - 
(01:33:48 PM) Babar: let me check something real quick...
(01:37:31 PM) gac410: I do think I need to scrap the try/except block in test_Package_fetchFile -  it fails to pass variables from inside the try block to outside.  So the asserts fail with undefined variables.    
(01:37:54 PM) Babar: yes, now I get it
(01:38:23 PM) Babar: you're doing a try within a try
(01:38:35 PM) gac410: I am?
(01:39:23 PM) gac410: Which issue - tar,  or fetchFile?   or is that same for both because Test framework also does try?
(01:40:47 PM) Babar: yes, exactly
(01:40:52 PM) Babar: test framework tries each test
(01:40:58 PM) Babar: and then you're trying something more in it
(01:41:03 PM) Babar: not sure this works
(01:42:07 PM) gac410: Ugh -   So sounds like as a rule, tests can't use try/catch?    what about when test runs core code that does try/catch?   
(01:42:52 PM) gac410: Oh - so that's the Assert issue with tar -   The core code catches the error instead of the test framework.
(01:44:00 PM) gac410: Sounds like the perl/core clergy needs to burn some incense over this one  :-)
(01:46:41 PM) Babar: yeah, I think we should ditch Error.pm and replace it with, I dunno... Try::Tiny? :)
(01:47:54 PM) gac410: Looking at http://search.cpan.org/dist/Error/lib/Error.pm   -  Maybe Exception::Class  or Error::Exception with plain eval?
(01:48:49 PM) gac410: [off]  gotta run for a while - the yardwork awaits  :-)
(01:50:25 PM) Babar: maybe Try::Tiny is enough :)
(01:57:58 PM) ***Babar has been advised Exception::Class::TryCatch
(01:58:01 PM) Babar: but for another time :)
...
(03:55:26 PM) gac410: grep against trunk - there really are not all that many instances of try or catch ... if it's going to be unpredictable, maybe it needs to be converted.

  • Does this need to be addressed?
  • When is the right time to address? 1.1, 2.0?

(05:26:18 PM) gac410: http://search.cpan.org/~drolsky/Exception-Class-1.30/lib/Exception/Class.pm#Catching_Exceptions   suggests using eval { }  instead of the try/catch syntax.   Bit more work but might be safer than try/catch.  
(05:27:31 PM) gac410: Also suggests gathering all exceptions into an separate Exceptions module.  This might be a good approach to support  i18n  for error messages.
(05:29:04 PM) gac410: Language specific Exception class subclasses the Foswiki::Exceptions class?
(05:30:57 PM) gac410: (and also facilitates a errors document)

-- GeorgeClark - 05 Jun 2010

References for exception handling:

-- GeorgeClark - 06 Jun 2010

Search results for try/catch

Omitting UnitTestContrib, the CPAN lib's themselves, and manually removing other unrelated. This is only a start, also need to look for throw, and Error:: references.

find . -type f | grep "\.pm$" | grep -v svn | grep -v UnitTestContrib | grep -v "\/branch" | xargs egrep "[[:space:]](try|catch)[[:space:]\{]" | sort



./ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin.pm:    catch Error::Simple with {
./ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin.pm:    catch Foswiki::AccessControlException with {
./ActionTrackerPlugin/lib/Foswiki/Plugins/ActionTrackerPlugin.pm:    try {                                       
./BuildContrib/lib/Foswiki/Contrib/Build.pm:            catch Error::Simple with {                                                                                                                            
./BuildContrib/lib/Foswiki/Contrib/Build.pm:            try {                                                                                                                                                 
./core/lib/Foswiki/EngineException.pm:All the above fields are accessible from the object in a catch clause                                                                                                   
./core/lib/Foswiki/Engine.pm:    catch Foswiki::EngineException with {                                                                                                                                        
./core/lib/Foswiki/Engine.pm:    try {                                                                                                                                                                        
./core/lib/Foswiki/Func.pm:    catch Error::Simple with {                                                                                                                                                     
./core/lib/Foswiki/Func.pm:    catch Error::Simple with {                                                                                                                                                     
./core/lib/Foswiki/Func.pm:   } catch Error::Simple with {                                                                                                                                                    
./core/lib/Foswiki/Func.pm:} catch Error::Simple with {                                                                                                                                                       
./core/lib/Foswiki/Func.pm:} catch Error::Simple with {                                                                                                                                                       
./core/lib/Foswiki/Func.pm:} catch Error::Simple with {                                                                                                                                                       
./core/lib/Foswiki/Func.pm:} catch Error::Simple with {                                                                                                                                                       
./core/lib/Foswiki/Func.pm:   } catch Foswiki::AccessControlException with {                                                                                                                                  
./core/lib/Foswiki/Func.pm:} catch Foswiki::AccessControlException with {                                                                                                                                     
./core/lib/Foswiki/Func.pm:} catch Foswiki::AccessControlException with {                                                                                                                                     
./core/lib/Foswiki/Func.pm:} catch Foswiki::AccessControlException with {                                                                                                                                     
./core/lib/Foswiki/Func.pm:} catch Foswiki::AccessControlException with {                                                                                                                                     
./core/lib/Foswiki/Func.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Func.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Func.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Func.pm:   try {                                                                                                                                                                           
./core/lib/Foswiki/Infix/Parser.pm:    catch Error::Simple with {                                                                                                                                             
./core/lib/Foswiki/Infix/Parser.pm:    try {                                                                                                                                                                  
./core/lib/Foswiki/Macros/FOREACH.pm:      catch Error::Simple with {                                                                                                                                         
./core/lib/Foswiki/Macros/FOREACH.pm:    try {                                                                                                                                                                
./core/lib/Foswiki/Macros/ICON.pm:            catch Error with {                                                                                                                                              
./core/lib/Foswiki/Macros/ICON.pm:            try {                                                                                                                                                           
./core/lib/Foswiki/Macros/IF.pm:    catch Foswiki::Infix::Error with {                                                                                                                                        
./core/lib/Foswiki/Macros/IF.pm:    try {                                                                                                                                                                     
./core/lib/Foswiki/Macros/INCLUDE.pm:    catch Error::Simple with {                                                                                                                                           
./core/lib/Foswiki/Macros/INCLUDE.pm:    try {                                                                                                                                                                
./core/lib/Foswiki/Macros/INCLUDE.pm:    try {                                                                                                                                                                
./core/lib/Foswiki/Macros/QUERY.pm:    catch Foswiki::Infix::Error with {                                                                                                                                     
./core/lib/Foswiki/Macros/QUERY.pm:    try {                                                                                                                                                                  
./core/lib/Foswiki/Macros/SEARCH.pm:    catch Error::Simple with {                                                                                                                                            
./core/lib/Foswiki/Macros/SEARCH.pm:    try {                                                                                                                                                                 
./core/lib/Foswiki/Meta.pm:    catch Error::Simple with {                                                                                                                                                     
./core/lib/Foswiki/Meta.pm:        } catch Foswiki::OopsException with {                                                                                                                                      
./core/lib/Foswiki/Meta.pm:    catch Foswiki::OopsException with {                                                                                                                                            
./core/lib/Foswiki/Meta.pm:        try {                                                                                                                                                                      
./core/lib/Foswiki/Meta.pm:        try {                                                                                                                                                                      
./core/lib/Foswiki/Meta.pm:        try {                                                                                                                                                                      
./core/lib/Foswiki/Meta.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Meta.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Meta.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Meta.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Meta.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Meta.pm:    try {                                                                                                                                                                          
./core/lib/Foswiki/Net.pm:        catch Error::Simple with {                                                                                                                                                  
./core/lib/Foswiki/Net.pm:    catch Error::Simple with {                                                                                                                                                      
./core/lib/Foswiki/Net.pm:        try {                                                                                                                                                                       
./core/lib/Foswiki/Net.pm:    try {                                                                                                                                                                           
./core/lib/Foswiki/PageCache.pm:    try {                                                                                                                                                                     
./core/lib/Foswiki/PageCache.pm:    # try to get a shared instance of this class                                                                                                                              
./core/lib/Foswiki/Plugin.pm:    catch Foswiki::AccessControlException with {                                                                                                                                 
./core/lib/Foswiki/Plugin.pm:    catch Foswiki::OopsException with {                                                                                                                                          
./core/lib/Foswiki/Plugin.pm:    catch Foswiki::ValidationException with {                                                                                                                                    
./core/lib/Foswiki/Plugin.pm:    try {                                                                                                                                                                        
./core/lib/Foswiki/Query/OP_ref.pm:        catch Error::Simple with {                                                                                                                                         
./core/lib/Foswiki/Query/OP_ref.pm:        try {                                                                                                                                                              
./core/lib/Foswiki/Search.pm:    catch Error::Simple with {                                                                                                                                                   
./core/lib/Foswiki/Search.pm:    catch Foswiki::Infix::Error with {                                                                                                                                           
./core/lib/Foswiki/Search.pm:    try {                                                                                                                                                                        
./core/lib/Foswiki/Search.pm:    try {                                                                                                                                                                        
./core/lib/Foswiki/UI/Changes.pm:        catch Foswiki::AccessControlException with {                                                                                                                         
./core/lib/Foswiki/UI/Changes.pm:        try {                                                                                                                                                                
./core/lib/Foswiki/UI/Edit.pm:        } catch Foswiki::OopsException with {                                                                                                                                   
./core/lib/Foswiki/UI/Edit.pm:        try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Manage.pm:    catch Error::Simple with {                                                                                                                                                
./core/lib/Foswiki/UI/Manage.pm:    catch Error::Simple with {                                                                                                                                                
./core/lib/Foswiki/UI/Manage.pm:    try {                                                                                                                                                                     
./core/lib/Foswiki/UI/Manage.pm:    try {                                                                                                                                                                     
./core/lib/Foswiki/UI.pm:    catch Error::Simple with {                                                                                                                                                       
./core/lib/Foswiki/UI.pm:    catch Foswiki::AccessControlException with {                                                                                                                                     
./core/lib/Foswiki/UI.pm:    catch Foswiki::EngineException with {                                                                                                                                            
./core/lib/Foswiki/UI.pm:    catch Foswiki::OopsException with {                                                                                                                                              
./core/lib/Foswiki/UI.pm:    catch Foswiki::ValidationException with {                                                                                                                                        
./core/lib/Foswiki/UI.pm:    try {                                                                                                                                                                            
./core/lib/Foswiki/UI/Register.pm:        catch Error::Simple with {                                                                                                                                          
./core/lib/Foswiki/UI/Register.pm:        catch Error::Simple with {                                                                                                                                          
./core/lib/Foswiki/UI/Register.pm:        catch Error::Simple with {                                                                                                                                          
./core/lib/Foswiki/UI/Register.pm:    catch Error::Simple with {                                                                                                                                              
./core/lib/Foswiki/UI/Register.pm:    catch Error::Simple with {                                                                                                                                              
./core/lib/Foswiki/UI/Register.pm:    catch Error::Simple with {                                                                                                                                              
./core/lib/Foswiki/UI/Register.pm:    catch Foswiki::OopsException with {                                                                                                                                     
./core/lib/Foswiki/UI/Register.pm:                try {                                                                                                                                                       
./core/lib/Foswiki/UI/Register.pm:        try {                                                                                                                                                               
./core/lib/Foswiki/UI/Register.pm:        try {                                                                                                                                                               
./core/lib/Foswiki/UI/Register.pm:        try {                                                                                                                                                               
./core/lib/Foswiki/UI/Register.pm:    try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Register.pm:    try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Register.pm:    try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Register.pm:    try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Register.pm:    try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Rename.pm:        catch Error::Simple with {                                                                                                                                            
./core/lib/Foswiki/UI/Rename.pm:        catch Error with {                                                                                                                                                    
./core/lib/Foswiki/UI/Rename.pm:    catch Error with {                                                                                                                                                        
./core/lib/Foswiki/UI/Rename.pm:        try {                                                                                                                                                                 
./core/lib/Foswiki/UI/Rename.pm:        try {                                                                                                                                                                 
./core/lib/Foswiki/UI/Rename.pm:    try {                                                                                                                                                                     
./core/lib/Foswiki/UI/Rest.pm:    catch Error with {                                                                                                                                                          
./core/lib/Foswiki/UI/Rest.pm:    # If there's login info, try and apply it                                                                                                                                   
./core/lib/Foswiki/UI/Rest.pm:    try {                                                                                                                                                                       
./core/lib/Foswiki/UI/Save.pm:        catch Error::Simple with {                                                                                                                                              
./core/lib/Foswiki/UI/Save.pm:        catch Error::Simple with {                                                                                                                                              
./core/lib/Foswiki/UI/Save.pm:    catch Error::Simple with {                                                                                                                                                  
./core/lib/Foswiki/UI/Save.pm:        try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Save.pm:        try {                                                                                                                                                                   
./core/lib/Foswiki/UI/Save.pm:    try {                                                                                                                                                                       
./core/lib/Foswiki/UI/Statistics.pm:        catch Foswiki::AccessControlException with {                                                                                                                      
./core/lib/Foswiki/UI/Statistics.pm:        try {                                                                                                                                                             
./core/lib/Foswiki/UI/Upload.pm:        catch Error::Simple with {                                                                                                                                            
./core/lib/Foswiki/UI/Upload.pm:    catch Error::Simple with {                                                                                                                                                
./core/lib/Foswiki/UI/Upload.pm:        catch Foswiki::AccessControlException with {                                                                                                                          
./core/lib/Foswiki/UI/Upload.pm:        catch Foswiki::OopsException with {                                                                                                                                   
./core/lib/Foswiki/UI/Upload.pm:        try {                                                                                                                                                                 
./core/lib/Foswiki/UI/Upload.pm:        try {                                                                                                                                                                 
./core/lib/Foswiki/UI/Upload.pm:    try {                                                                                                                                                                     
./core/lib/Foswiki/Users/ApacheHtpasswdUser.pm:        catch Error::Simple with {};                                                                                                                           
./core/lib/Foswiki/Users/ApacheHtpasswdUser.pm:    catch Error::Simple with {                                                                                                                                 
./core/lib/Foswiki/Users/ApacheHtpasswdUser.pm:    catch Error::Simple with {                                                                                                                                 
./core/lib/Foswiki/Users/ApacheHtpasswdUser.pm:        try {                                                                                                                                                  
./core/lib/Foswiki/Users/ApacheHtpasswdUser.pm:    try {                                                                                                                                                      
./core/lib/Foswiki/Users/ApacheHtpasswdUser.pm:    try {                                                                                                                                                      
./core/lib/Foswiki/Users/HtPasswdUser.pm:        catch Error::Simple with {                                                                                                                                   
./core/lib/Foswiki/Users/HtPasswdUser.pm:    catch Error::Simple with {                                                                                                                                       
./core/lib/Foswiki/Users/HtPasswdUser.pm:    catch Error::Simple with {                                                                                                                                       
./core/lib/Foswiki/Users/HtPasswdUser.pm:    # first try the mapping cache                                                                                                                                    
./core/lib/Foswiki/Users/HtPasswdUser.pm:        try {                                                                                                                                                        
./core/lib/Foswiki/Users/HtPasswdUser.pm:    try {                                                                                                                                                            
./core/lib/Foswiki/Users/HtPasswdUser.pm:    try {                                                                                                                                                            

Extensions

./DateTimePlugin/test/unit/DateTimePlugin/DateTimePluginTests.pm:    catch Error::Simple with {                                                                                                               
./DateTimePlugin/test/unit/DateTimePlugin/DateTimePluginTests.pm:    catch Foswiki::AccessControlException with {                                                                                             
./DateTimePlugin/test/unit/DateTimePlugin/DateTimePluginTests.pm:    try {                                                                                                                                    
./DBCachePlugin/lib/Foswiki/Plugins/DBCachePlugin/WebDB.pm:    catch Error::Simple with {                                                                                                                     
./DBCachePlugin/lib/Foswiki/Plugins/DBCachePlugin/WebDB.pm:    try {                                                                                                                                          
./DbiContrib/lib/Foswiki/Contrib/DbiContrib.pm:    catch Error::Simple with {                                                                                                                                 
./DbiContrib/lib/Foswiki/Contrib/DbiContrib.pm:    catch Error::Simple with {                                                                                                                                 
./DbiContrib/lib/Foswiki/Contrib/DbiContrib.pm:    catch Error::Simple with {                                                                                                                                 
./DbiContrib/lib/Foswiki/Contrib/DbiContrib.pm:    try {                                                                                                                                                      
./DbiContrib/lib/Foswiki/Contrib/DbiContrib.pm:    try {                                                                                                                                                      
./DbiContrib/lib/Foswiki/Contrib/DbiContrib.pm:    try {                                                                                                                                                      
./DbXmlPlugin/lib/Foswiki/Plugins/DbXmlPlugin.pm:      if (my $e = catch std::exception) { $failed = 1; };                                                                                                    
./DbXmlPlugin/lib/Foswiki/Plugins/DbXmlPlugin.pm:    if (my $e = catch XmlException)                                                                                                                          
./DbXmlPlugin/lib/Foswiki/Plugins/DbXmlPlugin.pm:    if (my $e = catch XmlException)                                                                                                                          
./DbXmlPlugin/lib/Foswiki/Plugins/DbXmlPlugin.pm:    if (my $e = catch XmlException) {                                                                                                                        
./DbXmlPlugin/lib/Foswiki/Plugins/DbXmlPlugin.pm:    if (my $e = catch XmlException) {                                                                                                                        
./FormPlugin/test/unit/FormPlugin/FormPluginTests.pm:    catch Error::Simple with {                                                                                                                           
./FormPlugin/test/unit/FormPlugin/FormPluginTests.pm:    catch Foswiki::AccessControlException with {                                                                                                         
./FormPlugin/test/unit/FormPlugin/FormPluginTests.pm:   } catch Foswiki::AccessControlException with {                                                                                                        
./FormPlugin/test/unit/FormPlugin/FormPluginTests.pm:    try {                                                                                                                                                
./FormPlugin/test/unit/FormPlugin/FormPluginTests.pm:   try {                                                                                                                                                 
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/lib/Foswiki/Plugins/FormQueryPlugin.pm:    try {                                                                                                                                            
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    catch Error::Simple with {                                                                                                                       
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    try {                                                                                                                                            
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    try {                                                                                                                                            
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    try {                                                                                                                                            
./FormQueryPlugin/test/unit/FormQueryPlugin/WebDBTest.pm:    try {                                                                                                                                            
./GenPDFAddOn/lib/Foswiki/Contrib/GenPDFAddOn.pm:    catch Error::Simple with {                                                                                                                               
./GenPDFAddOn/lib/Foswiki/Contrib/GenPDFAddOn.pm:        catch Foswiki::AccessControlException with {                                                                                                         
./GenPDFAddOn/lib/Foswiki/Contrib/GenPDFAddOn.pm:    { #?? Doesn't this try belong around the run of htmldoc?  CGI::header won't fail.
./GenPDFAddOn/lib/Foswiki/Contrib/GenPDFAddOn.pm:        try {                                                                                                                                                
./GenPDFLatexAddOn/lib/Foswiki/Contrib/GenPDFLatex.pm:    {                           # catch all nested <latex> tags!                                                                                        
./GetAWebPlugin/lib/Foswiki/Plugins/GetAWebPlugin.pm:            } catch Foswiki::AccessControlException with {                                                                                               
./GetAWebPlugin/lib/Foswiki/Plugins/GetAWebPlugin.pm:            try {                                                                                                                                        
./GoogleAnalyticsPlugin/test/unit/GoogleAnalyticsPlugin/GoogleAnalyticsPluginTests.pm:    catch Error::Simple with {                                                                                          
./GoogleAnalyticsPlugin/test/unit/GoogleAnalyticsPlugin/GoogleAnalyticsPluginTests.pm:    catch Foswiki::AccessControlException with {                                                                        
./GoogleAnalyticsPlugin/test/unit/GoogleAnalyticsPlugin/GoogleAnalyticsPluginTests.pm:    try {                                                                                                               
./HTTPDUserAdminContrib/lib/Foswiki/Users/HTTPDUserAdminUser.pm:            } catch Error::Simple with {                                                                                                      
./HTTPDUserAdminContrib/lib/Foswiki/Users/HTTPDUserAdminUser.pm:    } catch Error::Simple with {                                                                                                              
./HTTPDUserAdminContrib/lib/Foswiki/Users/HTTPDUserAdminUser.pm:    } catch Error::Simple with {                                                                                                              
./HTTPDUserAdminContrib/lib/Foswiki/Users/HTTPDUserAdminUser.pm:            try {                                                                                                                             
./HTTPDUserAdminContrib/lib/Foswiki/Users/HTTPDUserAdminUser.pm:    try {                                                                                                                                     
./HTTPDUserAdminContrib/lib/Foswiki/Users/HTTPDUserAdminUser.pm:    try {                                                                                                                                     
./HTTPEngineContrib/lib/Foswiki/Engine/HTTP/Server.pm:    catch Error::Simple with {                                                                                                                          
./HTTPEngineContrib/lib/Foswiki/Engine/HTTP/Server.pm:    try {                                                                                                                                               
./ImagePlugin/lib/Foswiki/Plugins/ImagePlugin/Core.pm:  catch Foswiki::OopsException with {                                                                                                                   
./ImagePlugin/lib/Foswiki/Plugins/ImagePlugin/Core.pm:  try {                                                                                                                                                 
./JQueryLibPlugin/lib/Foswiki/Plugins/JQueryLibPlugin.pm:Plugins should try to resolve differences and return the merged text.                                                                                
./KinoSearchContrib/lib/Foswiki/Contrib/KinoSearchContrib/StringifierPlugins/XLS.pm:    catch Error with {                                                                                                    
./KinoSearchContrib/lib/Foswiki/Contrib/KinoSearchContrib/StringifierPlugins/XLS.pm:    try {                                                                                                                 
./KinoSearchContrib/lib/Foswiki/Contrib/KinoSearchContrib/StringifierPlugins/XLSX.pm:    catch Error with {                                                                                                   
./KinoSearchContrib/lib/Foswiki/Contrib/KinoSearchContrib/StringifierPlugins/XLSX.pm:    try {                                                                                                                
./MailInContrib/lib/Foswiki/Contrib/MailInContrib.pm:    catch Error::Simple with {                                                                                                                           
./MailInContrib/lib/Foswiki/Contrib/MailInContrib.pm:    catch Foswiki::AccessControlException with {                                                                                                         
./MailInContrib/lib/Foswiki/Contrib/MailInContrib.pm:    try {                                                                                                                                                
./MediaPlugin/lib/Foswiki/Plugins/MediaPlugin.pm:    catch Error::Simple with {                                                                                                                               
,/PhpBB3UsersContrib/lib/Foswiki/Users/PhpBB3UserMapping.pm:        catch Error::Simple with {                                                                                                                
./PhpBB3UsersContrib/lib/Foswiki/Users/PhpBB3UserMapping.pm:        catch Error::Simple with {                                                                                                                
./PhpBB3UsersContrib/lib/Foswiki/Users/PhpBB3UserMapping.pm:        try {                                                                                                                                     
./PhpBB3UsersContrib/lib/Foswiki/Users/PhpBB3UserMapping.pm:        try {                                                                                                                                     
./PublishPlugin/lib/Foswiki/Plugins/PublishPlugin/Publisher.pm:        catch Error::Simple with {                                                                                                             
./PublishPlugin/lib/Foswiki/Plugins/PublishPlugin/Publisher.pm:        try {                                                                                                                                  
./QueryAcceleratorPlugin/lib/Foswiki/Store/QueryAlgorithms/DBCache.pm:        catch Error::Simple with {};                                                                                                    
./QueryAcceleratorPlugin/lib/Foswiki/Store/QueryAlgorithms/DBCache.pm:        try {                                                                                                                           
./QuizPlugin/lib/TWiki/Plugins/QuizPlugin.pm:           alert(\"You should try at least once before clicking on 'Show Solutions'!\");                                                                         
./SetTopicValuesPlugin/lib/Foswiki/Plugins/SetTopicValuesPlugin.pm:                } catch  Error::Simple with {                                                                                              
./SetTopicValuesPlugin/lib/Foswiki/Plugins/SetTopicValuesPlugin.pm:                try {                                                                                                                      
./SoapClientPlugin/lib/Foswiki/Plugins/SoapClientPlugin.pm:    } catch Error::Simple with {                                                                                                                   
./SoapClientPlugin/lib/Foswiki/Plugins/SoapClientPlugin.pm:    try {                                                                                                                                          
./SoapPlugin/lib/Foswiki/Plugins/SoapPlugin/Client.pm:  } catch Error::Simple with {                                                                                                                          
./SoapPlugin/lib/Foswiki/Plugins/SoapPlugin/Client.pm:  try {                                                                                                                                                 
./SqlPlugin/lib/Foswiki/Plugins/SqlPlugin/Core.pm:  } catch Error::Simple with {                                                                                                                              
./SqlPlugin/lib/Foswiki/Plugins/SqlPlugin/Core.pm:  } catch Error::Simple with {                                                                                                                              
./SqlPlugin/lib/Foswiki/Plugins/SqlPlugin/Core.pm:  try {                                                                                                                                                     
./SqlPlugin/lib/Foswiki/Plugins/SqlPlugin/Core.pm:  try {                                                                                                                                                     
./StringifierContrib/lib/Foswiki/Contrib/StringifierContrib/Plugins/XLSX.pm:  catch Error with {                                                                                                              
./StringifierContrib/lib/Foswiki/Contrib/StringifierContrib/Plugins/XLSX.pm:  try {                                                                                                                           
./TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm:        catch Error::Simple with {                                                                                                                      
./TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm:        try {                                                                                                                                           
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/ChangeOwner.pm:    catch Error::Simple with {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/ChangeOwner.pm:    try {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Delete.pm:    catch Error::Simple with {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Delete.pm:    try {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Merge.pm:    catch Error::Simple with {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Merge.pm:    try {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Public.pm:    catch Error::Simple with {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Public.pm:    try {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Rename.pm:    catch Error::Simple with {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Rename.pm:    try {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Tag.pm:    catch Error::Simple with {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Tag.pm:    try {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Untag.pm:    catch Error::Simple with {
./TagsPlugin/lib/Foswiki/Plugins/TagsPlugin/Untag.pm:    try {
./TaskExePlugin/lib/TWiki/Plugins/TaskExePlugin.pm:Plugins should try to resolve differences and return the merged text.
./ThumbnailPlugin/lib/Foswiki/Plugins/ThumbnailPlugin.pm:         } catch Error::Simple with {
./ThumbnailPlugin/lib/Foswiki/Plugins/ThumbnailPlugin.pm:         } catch Error::Simple with {
./ThumbnailPlugin/lib/Foswiki/Plugins/ThumbnailPlugin.pm:         try {
./ThumbnailPlugin/lib/Foswiki/Plugins/ThumbnailPlugin.pm:         try {
./TopicUserMappingContrib/lib/Foswiki/Users/TopicUserMapping.pm:    catch Error::Simple with {
./TopicUserMappingContrib/lib/Foswiki/Users/TopicUserMapping.pm:    try {
./TopicUserMappingContrib/test/unit/TopicUserMappingContrib/TopicUserMappingTests.pm:    catch Error::Simple with {
./TopicUserMappingContrib/test/unit/TopicUserMappingContrib/TopicUserMappingTests.pm:    catch Foswiki::AccessControlException with {
./TopicUserMappingContrib/test/unit/TopicUserMappingContrib/TopicUserMappingTests.pm:    try {
./UploadPlugin/lib/Foswiki/Plugins/UploadPlugin/Core.pm:    } catch Error::Simple with {
./UploadPlugin/lib/Foswiki/Plugins/UploadPlugin/Core.pm:    try {
./WebAutoIncPlugin/lib/Foswiki/Plugins/WebAutoIncPlugin.pm:      catch Error::Simple with {
./WebAutoIncPlugin/lib/Foswiki/Plugins/WebAutoIncPlugin.pm:      catch Foswiki::AccessControlException with {
./WebAutoIncPlugin/lib/Foswiki/Plugins/WebAutoIncPlugin.pm:    try {
./WikiBot/lib/Mails.pm:try and try again (unless you kill me...) but it was fruitless.
./WorkflowPlugin/lib/Foswiki/Plugins/WorkflowPlugin.pm:        } catch Error::Simple with {
./WorkflowPlugin/lib/Foswiki/Plugins/WorkflowPlugin.pm:    } catch Foswiki::OopsException with {
./WorkflowPlugin/lib/Foswiki/Plugins/WorkflowPlugin.pm:        try {
./WorkflowPlugin/lib/Foswiki/Plugins/WorkflowPlugin.pm:    try {
./WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/Handlers.pm:    catch Error::Simple with {
./WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/Handlers.pm:    # Switch off wysiwyg_edit so it doesn't try to transform again in
./WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/Handlers.pm:    try {
./X509UserPlugin/lib/Foswiki/Users/X509PasswdUser.pm:        } catch Error::Simple with {
./X509UserPlugin/lib/Foswiki/Users/X509PasswdUser.pm:    } catch Error::Simple with {
./X509UserPlugin/lib/Foswiki/Users/X509PasswdUser.pm:    } catch Error::Simple with {
./X509UserPlugin/lib/Foswiki/Users/X509PasswdUser.pm:        try {
./X509UserPlugin/lib/Foswiki/Users/X509PasswdUser.pm:    try {
./X509UserPlugin/lib/Foswiki/Users/X509PasswdUser.pm:    try {
./X509UserPlugin/lib/Foswiki/Users/X509UserMapping.pm:  } catch Error::Simple with {
./X509UserPlugin/lib/Foswiki/Users/X509UserMapping.pm:  try {
./XmlXslPlugin/lib/TWiki/Plugins/XmlXslPlugin.pm:               try {

We definitely need to do this - tho it will be important to work out a strategy for allowing non-public third party plugins to cope with mixing our new mechanism and their older Error.pm based one - or at least to make it easy.

I recon we should schedule this to happen as early in the 1.2/2.0 development cycle, so that we can shake it as much as possible.

-- SvenDowideit - 06 Jun 2010

If the 2.0 milestone is the new UI/skin that Carlos and Arthur have been working on, then I agree that we could do a 1.2 which has this issue taken care of and hopefully a couple of other things (Eg. wysiwyg support for underline and strikeout that has already been accepted).

I will have to do some research before offering any input to suitable replacements.

-- PaulHarvey - 06 Jun 2010

So what's the consensus here? Will we be able to keep our custom exception classes and still not drag in moose?

-- MichaelDaum - 31 Jan 2011

This smacks of re-engineering for the sake of it.

-- CrawfordCurrie - 31 Jan 2011

For the sake of it? You've not lost time due to inconsistencies between behaviour when FOSWIKI_ASSERTS=1, when unit tests are run, when Foswiki is used in production and not to mention my favourite one of all, the empty abyss that is the apache/foswiki logs when errors are clearly thrown or code clearly doesn't compile - just because the cosmical alignment of eval/try/catch soaks up such errors into the void?

-- PaulHarvey - 01 Feb 2011

Speaking of re-engineering, I'm hopeful a switch to Try::Tiny or whatever (I really don't care) is "just" a matter of a simple sed script with some human review.

Our exception handling sucks.

-- PaulHarvey - 01 Feb 2011

I really hoped Try::Tiny was a drop-in replacement. While it does provide try/catch/finally syntax, it does not allow to define custom exception. That's only possible with Excetion::Class. What exactly are the pros and cons of Try::Tiny and Exception::Class:TryCatch?

Someone on irc said that the Exception::Class* stuff adds a dependency to Moose. Is that true? That would be quite fat for a replacement.

The other option is to send over our Error.pm patches to the original author and - if he abandoned the project - fix it ourselves and take over maintenance. It could very well be that this is less effort. This is at least worth considering as Error.pm is deep into our code.

-- MichaelDaum - 01 Feb 2011

Actually, I have lost time to it - I dislike Error.pm as much as anyone. However, I haven't seen anything else better, and my gut tells me "better the devil you know". Alternatively, is there some way we can check syntax usage? Or, as Micha suggests, boil our own?

-- CrawfordCurrie - 01 Feb 2011

before we invoke the not invented here fear, how about we actually try the ones we're advised to try - and only if we can't achieve what we desperately need, go baroque?

-- SvenDowideit - 02 Feb 2011

If WillNorris is right, sounds like Exception::Class is worth looking in to.

-- PaulHarvey - 02 Feb 2011
 

BasicForm edit

TopicClassification BrainStorming
TopicSummary CPAN Error.pm contains a strong warning that it should not be used. Should this be fixed, and when.
InterestedParties
Topic revision: r13 - 02 Feb 2011, PaulHarvey
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy