This is an initial PR for Issue #70 and handling of frame errors in general. #80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR consists of the following and I'd like us to discuss it so that it can perhaps be fully implemented if everyone is happy with the way it works:
FrameException
extendsBunnyException
FrameSoftErrorException
extendsFrameException
FrameHardErrorException
extendsFrameException
The generator will generate all the soft error and hard error frame exceptions source code in the format:
FrameHardError???Exception
andFrameSoftError???Exception
, these extend eitherFrameHardErrorException
orFrameSoftErrorException
depending on the error type. Examples are:FrameHardError320Exception
andFrameSoftError404Exception
The generator also generates a new class called
FrameError
underBunny/Protocol
. This class can determine and return the appropriate exception for any given frame. For example, inChannel.php
on line 624 you have the following statement:This can be replaced with something like:
Which will throw the following exception if one attempts to publish a message to an exchange called
whoops
which doesn't exist:Bunny\Exception\FrameSoftError404Exception: Channel method frame error received.: AMQP Error: "404 NOT_FOUND - no exchange 'whoops' in vhost '/'" in class Bunny\Protocol\MethodChannelCloseFrame (channel:close).
As you can see the error is quite detailed. The
FrameError
class will automatically drop to a lower detailed error message depending on the type of frame and the information it has available (i.e. replyCode, replyText, classId, methodId, etc.)If the frame does not have replyCode and replyText properties a FrameException will be returned instead of one of the hard or soft exceptions.
FrameSoftError404Exception
inFrameSoftErrorTest.php
which tests publishing a messages to a non existing exchange calledwhoops
. You can play around with it by commenting out line 21 so that it shows the exception instead of testing against it.I'm happy to discuss and answer any questions.