Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

shrikeh
Copy link

@shrikeh shrikeh commented Oct 18, 2022

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
    );      
}

@BenMorel
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants