]> git.mxchange.org Git - hub.git/commitdiff
Now use a try/catch block
authorRoland Häder <roland@mxchange.org>
Tue, 7 Aug 2012 16:23:54 +0000 (16:23 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 7 Aug 2012 16:23:54 +0000 (16:23 +0000)
application/hub/exceptions/package/class_FinalChunkVerificationException.php
application/hub/main/class_BaseHubSystem.php
application/hub/main/handler/chunks/class_ChunkHandler.php

index 6d6d423c4c8d059ae478ac2a8d384a90e9bc0790..5fb73545cca4ee89b5c3f0e3e7abf3ea9814427a 100644 (file)
@@ -32,12 +32,13 @@ class FinalChunkVerificationException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf("[%s:%d] The final chunk %s is not a valid EOP (%s) chunk. Total chunks: %s",
+               $message = sprintf("[%s:%d] The final chunk %s is not a valid EOP (%s) chunk. Total chunks: %s, cause: %s",
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $messageArray[1][count($messageArray[1]) - 1],
                        PackageFragmenter::END_OF_PACKAGE_IDENTIFIER,
-                       count($messageArray[1])
+                       count($messageArray[1]),
+                       $messageArray[2]->__toString()
                );
 
                // Call parent exception constructor
index 9d84ce9ba7c7ca7973977541cec64570d3a13731..3d0db1f6aca9f8e45e807acf86f2bccf4f22c5d2 100644 (file)
@@ -450,7 +450,7 @@ class BaseHubSystem extends BaseFrameworkSystem {
                $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]);
 
                // Make sure chunks with only 3 elements are parsed (for details see ChunkHandler)
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits,true));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, true));
                assert(count($chunkSplits) == 3);
 
                // Validate final chunk
index 739e07e247bfd2b7a0ae9bca34f214d1d706fdc9..e8b104ad03b88282622f1ade6a16d1479dffecf3 100644 (file)
@@ -358,11 +358,14 @@ class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable
         * @throws      FinalChunkVerificationException         If the final chunk does not start with 'EOP:'
         */
        public function addAllChunksWithFinal (array $chunks) {
-               // Validate final chunk
-               if (!$this->isValidFinalChunk($chunks)) {
+               // Try to validate the final chunk
+               try {
+                       // Validate final chunk
+                       $this->isValidFinalChunk($chunks);
+               } catch (AssertionException $e) {
                        // Last chunk is not valid
-                       throw new FinalChunkVerificationException(array($this, $chunks), BaseListener::EXCEPTION_FINAL_CHUNK_VERIFICATION);
-               } // END - if
+                       throw new FinalChunkVerificationException(array($this, $chunks, $e), BaseListener::EXCEPTION_FINAL_CHUNK_VERIFICATION);
+               }
 
                // Do we have some pending chunks (no final)?
                while (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_CHUNKS_WITHOUT_FINAL)) {