php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69318 Expose status value as HaruException::$code
Submitted: 2015-03-27 23:11 UTC Modified: 2015-03-31 00:36 UTC
From: p at wspnr dot com Assigned:
Status: Closed Package: haru (PECL)
PHP Version: 5.6.7 OS: Linux
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.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: p at wspnr dot com
New email:
PHP Version: OS:

 

 [2015-03-27 23:11 UTC] p at wspnr dot com
Description:
------------
The HPDF_STATUS value that is used to generate the HaruException message should be included as the exception code. Currently, the exception code is always set to 0.

The status value is already available at the point of the zend_throw_exception_ex() call, so this should be a fairly simple change.

This would be very helpful during debugging, as:

- There is not a 1:1 mapping of HPDF_STATUS codes to friendly exception messages. The same message can be generated from different status codes.
- Since this extension is a paper-thin wrapper around libharu, debugging usually leads back to the libharu source and documentation. Being able to find where a given error is raised in the libharu code would be very helpful.

I can get a patch/PR written for this.



Test script:
---------------
/* This code will raise an HPDF_ARRAY_COUNT_ERR, numeric value 0x1001 or 4097 */

$d = new HaruDoc();

try {
    while(true) {
        $d->addPage();
    }
} catch(HaruException $ex) {
    var_dump($ex);
}

Expected result:
----------------
class HaruException#2 (8) {
  protected $message =>
  string(60) "libharu internal error. The consistency of the data was lost"
  private $string =>
  string(0) ""
  protected $code =>
  int(4097)
  ... snip ...
}

Actual result:
--------------
class HaruException#2 (8) {
  protected $message =>
  string(60) "libharu internal error. The consistency of the data was lost"
  private $string =>
  string(0) ""
  protected $code =>
  int(0)
  ... snip ...
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-27 23:53 UTC] p at wspnr dot com
Added PR on GitHub
 [2015-03-31 00:36 UTC] p at wspnr dot com
-Status: Open +Status: Closed
 [2015-03-31 00:36 UTC] p at wspnr dot com
PR was merged
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 16 07:01:27 2024 UTC