postcode icon indicating copy to clipboard operation
postcode copied to clipboard

Add exception interface for easier catching without having to intimately know the library

Open shrikeh opened this issue 2 years ago • 1 comments

Simple interface applied to all exceptions, allowing code such as:

...
use Brick\Postcode\PostcodeException;

try {
    $postcodeFormatter->format('GB', $invalidPostcode);
} catch (PostcodeException $e) {
    throw new ApplicationSpecificException(
        sprintf('There was a problem with formatting the postcode "%s"', $invalidPostcode),
        0,
        $e
    );      
}

shrikeh avatar Oct 18 '22 10:10 shrikeh

Hi, I guess you can just make PostcodeException the base class as none of the existing exceptions need to extend a particular base class at the moment?

BenMorel avatar Oct 26 '22 22:10 BenMorel