/    Sign up×
Community /Pin to ProfileBookmark

exception not caught (Namespace issue?)

Hi All

I’m using doctrine, and at some point it throws an DoctrineORMNoResultException exception.

So I tried to catch it like

[CODE]
try {
$qb = $em->createQueryBuilder();
$qb->add(‘select’, ‘u.name’)
->add(‘select’, ‘u.passwd’)
->add(‘from’, ‘EntitiesUser u’)
->add(‘where’, ‘u.name = ?1’)
->setParameter(1,$_POST[‘usern’]);
$q = $qb->getQuery();
$result = $q->execute();
} catch (DoctrineORMNoResultException $e) {
echo “{login: false}” ;
return ;
}
[/CODE]

Whatever I try I can’t catch the exception. I read somewhere that you should add

[CODE]
use DoctrineORM ;
[/CODE]

but that didn’t fix it

Any suggestions ?

thnx
Luca

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 06.2010 — I'm not real up to speed on namespaces, but since each exception class extends the global Exception class, perhaps you have to reference it from the Global namespace?
<i>
</i>catch(GlobalYourExceptionClass $e)

Again, I'm only guessing here, so no promises. ?
Copy linkTweet thisAlerts:
@jeanlucaauthorDec 06.2010 — my mistake!

I executed this code at 2 places. One with try/catch and the other without!

sorry!

cheers
×

Success!

Help @jeanluca spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...