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

Exception handling #28

Open
sami616 opened this issue Feb 1, 2017 · 2 comments
Open

Exception handling #28

sami616 opened this issue Feb 1, 2017 · 2 comments

Comments

@sami616
Copy link

sami616 commented Feb 1, 2017

Hi, I'm having some difficulty understanding how exception handling would work. I'm having some trouble catching the below Exception for example. I'm thinking i'm perhaps in the wrong namespace and/or trying to catch the wrong Exception?

namespace DotMailer\Api\DataTypes;

$contact = new ApiContact();
$contact->email = $_POST['email'];
$contact->emailtype = $_POST['email_type'];


try {
	$contact = $resources->PostContacts('invalid input');
} catch (Exception $e) {
	echo $e->getMessage();
}
@romanpitak
Copy link
Owner

i'm perhaps in the wrong namespace

Probably

The exception should probably be \DotMailer\Api\Exception (note the backslash at the beginning).

@sami616
Copy link
Author

sami616 commented Feb 1, 2017

Thanks! I still seem to be having an issue with successfully catching the exception. Could you supply an example?

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

2 participants