php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #29495 New DOM and XSL classes should throw exceptions.
Submitted: 2004-08-02 18:15 UTC Modified: 2016-09-29 17:31 UTC
Votes:4
Avg. Score:5.0 ± 0.0
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: tony at marston-home dot demon dot co dot uk Assigned: cmb (profile)
Status: Closed Package: *General Issues
PHP Version: 5.0.0 OS: *
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tony at marston-home dot demon dot co dot uk
New email:
PHP Version: OS:

 

 [2004-08-02 18:15 UTC] tony at marston-home dot demon dot co dot uk
Description:
------------
I have just started using the new DOM and XSL classes in PHP5, and one thing I really find annoying is the difficulty in trapping errors. I tried to use the new try... catch... syntax but this does not work.

I have worked out another way of detecting errors from these two classes, but it is very messy. Can they be changed to use the new try...cath... syntax?


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-03 10:01 UTC] chregu@php.net
PHP 5.1 will have new error handling functionality (nothing written yet, but will almost certainly not use try/catch but error handler callbacks)

You have to wait for that... 
 [2005-01-28 22:50 UTC] rodent at mighty dot co dot za
I don't really see why try/catch shouldn't be used for things like loadXML.

A DOMException is raised for EVERYTHING but loadXML, or load.

Why should they be treated differently from the other DOM methods? It's been a real pain porting my sablotron based XML/XSLT transformation code to php5, and even with all the hacks I implemented, it's nowhere NEAR the kind of error reporting I could do with the sablotron XSLT module.

I truly believe this should be reinvestigated.
 [2005-01-28 23:45 UTC] amt@php.net
One of the main goals of the PHP 5 DOM extension is trying to obey the DOM spec whenever possible. Therefore, the policy is that DOM always throws exceptions:

1) In the constructor (this is a PHP 5 issue)
2) Where the DOM spec says an exception should be omitted

The loadXML() method is probably an edge case, as I don't believe it's part of the official DOM spec. I actually think it's no longer part of the recommendation, but we're keeping it in for backwards compatibility.

Regardless, this method was prototyped to return a boolean and not throw an exception.

http://www.w3.org/TR/2002/WD-DOM-Level-3-LS-20020725/load-save.html#LS-DocumentLS-loadXML

So that's what it does.
 [2005-02-01 18:03 UTC] chregu@php.net
This is not a discussion forum. We will have better error-reporting in PHP 5.1. *Not* based on exceptions. Stop whining  or contribute code ;)

bug closed
 [2016-09-29 17:31 UTC] cmb@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2016-09-29 17:31 UTC] cmb@php.net
-Status: Suspended +Status: Closed -Assigned To: +Assigned To: cmb
 [2016-09-29 17:31 UTC] cmb@php.net
Well, PHP 5.1 brought libxml_use_internal_errors() and friends, so
this ticket can be closed.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun May 11 06:01:29 2025 UTC