svn: /pear/packages/Payment_DTA/trunk/ DTA.php

From: Date: Mon, 06 Sep 2010 16:05:02 +0000
Subject: svn: /pear/packages/Payment_DTA/trunk/ DTA.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-60281@lists.php.net to get a copy of this message
mschuett Mon, 06 Sep 2010 16:05:02 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=303097 Log: report file offset in exceptions, with multiple errors the transaction count alone is misleading Changed paths: U pear/packages/Payment_DTA/trunk/DTA.php Modified: pear/packages/Payment_DTA/trunk/DTA.php =================================================================== --- pear/packages/Payment_DTA/trunk/DTA.php 2010-09-06 15:55:34 UTC (rev 303096) +++ pear/packages/Payment_DTA/trunk/DTA.php 2010-09-06 16:05:02 UTC (rev 303097) @@ -711,6 +711,9 @@ */ private function _parseCrecord($input, &$offset, &$checks) { + // save for possible exceptions + $c_start = $offset; + /* field 1 */ $record_length = $this->getNum($input, $offset, 4); /* field 2 */ @@ -743,8 +746,8 @@ '(' . $Ctype . ') '. 'does not match A record type indicator '. '(' . (($this->type == DTA_CREDIT) ? "CREDIT" : "DEBIT") . ') '. - 'in transaction number '. - strval($this->count()+1)); + 'in transaction number '. strval($this->count()+1) . + ' @ offset '. strval($c_start)); } /* field 8 */ $this->checkStr($input, $offset, " "); @@ -777,7 +780,7 @@ if ($extensions != $extensions_length) { throw new Payment_DTA_ParseException('number of extensions '. 'does not match record length in transaction number '. - strval($this->count()+1)); + strval($this->count()+1) .' @ offset '. strval($c_start)); } // extensions to C record, read into array & processed later @@ -838,7 +841,8 @@ // should never happen throw new Payment_DTA_ParseException('confused about '. 'number of extensions in transaction number '. - strval($this->count()+1) .', please file a bug report'); + strval($this->count()+1) .' @ offset '. strval($c_start) . + ', please file a bug report'); } // and one switch for the padding @@ -868,7 +872,7 @@ if (!empty($Creceiver_name2)) { throw new Payment_DTA_ParseException('multiple '. 'receiver name extensions in transaction number '. - strval($this->count()+1)); + strval($this->count()+1) .' @ offset '. strval($c_start)); } else { $Creceiver_name2 = $ext_content; } @@ -878,7 +882,7 @@ // allowed: 1 line in fixed part + 13 in extensions throw new Payment_DTA_ParseException('too many '. 'purpose extensions in transaction number '. - strval($this->count()+1)); + strval($this->count()+1) .' @ offset '. strval($c_start)); } else { array_push($Cpurpose, $ext_content); } @@ -887,7 +891,7 @@ if (!empty($Csender_name2)) { throw new Payment_DTA_ParseException('multiple '. 'receiver name extensions in transaction number '. - strval($this->count()+1)); + strval($this->count()+1) .' @ offset '. strval($c_start)); } else { $Csender_name2 = $ext_content; } @@ -895,7 +899,7 @@ default: throw new Payment_DTA_ParseException('invalid '. 'extension type in transaction number '. - strval($this->count()+1)); + strval($this->count()+1) .' @ offset '. strval($c_start)); } } @@ -925,9 +929,9 @@ ); if (!$rc) { // should never happen - throw new Payment_DTA_ParseException("Cannot addExchange() ". - "for transaction number ".strval($this->count()+1). - ", please file a bug report", $e); + throw new Payment_DTA_ParseException('Cannot addExchange() '. + 'for transaction number '.strval($this->count()+1) . + ' @ offset '. strval($c_start). ', please file a bug report', $e); } $checks['account'] += $Creceiver_account; $checks['blz'] += $Creceiver_blz; @@ -1060,7 +1064,7 @@ // preserve error $this->allerrors[] = new Payment_DTA_ParseException( "Error in C record, in transaction number ". - strval($this->count()+1), $e); + strval($this->count()+1) ." @ offset ". strval($c_start), $e); // skip to next 128-byte aligned record $offset = $c_start + 128 * (1 + intval($c_length/128)); }

« previous php.pear.cvs (#60281) next »