// ...
That's from memory, so there may be a few errors.
Seems there was. Try this:
class DBException extends Exception {}
try {
$connection = mysql_connect(...);
if (!$connection) {
throw new DBException('Failed to connect to database');
}
// Database exception handling
Does that mean for every exception do we have to write
our custom exception and describe it from our own
message
If you mean "Do I have to write custom exception classes?", the no. You
could just use the PHP Exception class.
Eg.
class DBException extends Exception {}
try {
$connection =
On Thu, 2008-02-07 at 00:20 -0800, Prabath Kumarasinghe wrote:
> Understood, Thanks Paul
>
Pleasure, but please don't top post, it makes it really hard to follow a
thread easily. Most people on this list take time out from their really
busy day jobs to help out, and the more time that everyone
Understood, Thanks Paul
Cheers
Prabath
--- Paul Scott <[EMAIL PROTECTED]> wrote:
>
> On Wed, 2008-02-06 at 23:37 -0800, Prabath
> Kumarasinghe wrote:
> > Does that mean for every exception do we have to
> write
> > our custom exception and describe it from our own
> > message
> >
>
> No, it me
On Wed, 2008-02-06 at 23:37 -0800, Prabath Kumarasinghe wrote:
> Does that mean for every exception do we have to write
> our custom exception and describe it from our own
> message
>
No, it means that when you want to throw a meaningful exception, you
need to type in a message. I mentioned cust
Does that mean for every exception do we have to write
our custom exception and describe it from our own
message
Cheers
Prabath
--- Paul Scott <[EMAIL PROTECTED]> wrote:
>
> On Wed, 2008-02-06 at 23:10 -0800, Prabath
> Kumarasinghe wrote:
> > Is this following code work in PHP if
> mysql_conne
On Wed, 2008-02-06 at 23:10 -0800, Prabath Kumarasinghe wrote:
> Is this following code work in PHP if mysql_connect
> fails.
>
> try{
> mysql_connect('localhost','user','');
>
> }catch(Exception $e){
> echo $e->getMessage();
>
Probably not. I don't think that the mysql functions throw excep
Hi Paul
Is this following code work in PHP if mysql_connect
fails.
try{
mysql_connect('localhost','user','');
}catch(Exception $e){
echo $e->getMessage();
}
Cheers
Prabath
--- Paul Scott <[EMAIL PROTECTED]> wrote:
>
> On Wed, 2008-02-06 at 22:52 -0800, Prabath
> Kumarasinghe wrote:
> > H
On Wed, 2008-02-06 at 22:52 -0800, Prabath Kumarasinghe wrote:
> Hi All
>
> I'm little bit confusing with PHP exception handling.
> Could you able to explain how to put try{} and
> catch(){} in a proper way in PHP. I had already read
> php exception manual but it didn't help me to get
> exact id
I think that would be nice to have a try-catch to better control of the
code.
Ovidiu
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 27, 2001 9:09 PM
> To: kevin1; [EMAIL PROTECTED]
> Subject: Re: [PHP] Exception
Addressed to: kevin1 <[EMAIL PROTECTED]>
[EMAIL PROTECTED]
** Reply to note from kevin1 <[EMAIL PROTECTED]> Tue, 27 Feb 2001 08:10:05 -0500
>
> Is there any equivalent to Java's try-catch or Perl's eval{BLOCK}if($@)
> structure in PHP?
No.
There has been some discussion about addi
11 matches
Mail list logo