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

Filter should use exceptions #34

Closed
mbrevda opened this issue Jan 21, 2014 · 5 comments
Closed

Filter should use exceptions #34

mbrevda opened this issue Jan 21, 2014 · 5 comments

Comments

@mbrevda
Copy link

mbrevda commented Jan 21, 2014

Validating code ends up requiring lots of if statements. Filter should be callable without worrying about its response, with exceptions throw to halt execution, when necessary.

for example:
Boilerplate:

$this->filter(...);
$data = ['foo' => 'bar'];

Before:

$success = $filter->values($data);
if (! $success) {
    $messages = $filter->getMessages();
    // do something with $messages;
}

After:

// exceptions can be caught anywhere in the stack
$filter->values($data);
@harikt
Copy link
Member

harikt commented Aug 2, 2014

I don't think so.

@pmjones
Copy link
Member

pmjones commented Dec 28, 2014

Wish granted! See the new develop-2 work, via __invoke(), where a FilterFailed exception is thrown.

@pmjones pmjones closed this as completed Dec 28, 2014
@mbrevda
Copy link
Author

mbrevda commented Dec 29, 2014

So now filters can be called either as invokables or with ->getValues(), correct? (In my current stack, I specifically DONT want an exception thrown...)

@pmjones
Copy link
Member

pmjones commented Dec 29, 2014

Or as ->values(), yes. Only __invoke() will throw the exception.

@mbrevda
Copy link
Author

mbrevda commented Dec 29, 2014

perfect

On Mon Dec 29 2014 at 3:45:38 PM Paul M. Jones notifications@github.com
wrote:

Or as ->values(), yes. Only __invoke() will throw the exception.


Reply to this email directly or view it on GitHub
#34 (comment).

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

No branches or pull requests

3 participants