473,320 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

strange behavior of class: lose data on throw exception.

Hallo,
I use a class vith a vaiables.
When a function throws an exception it seems to loose data:

....
$c=new myclass();
try{
$a->var1=1;
$a->function_throw_exception(); <--- this throws an exception
...
}
catche(exception $e)
{
$a->var1; <--- is empty ?!?!
}

The code is more complex but the idea is this.
it is possible?
what do you think?
Thankyou in advance,
Mario.
May 2 '07 #1
1 1187
On May 2, 4:17 pm, "_mario.lat" <n...@libero.itwrote:
Hallo,
I use a class vith a vaiables.
When a function throws an exception it seems to loose data:

...
$c=new myclass();
try{
$a->var1=1;
$a->function_throw_exception(); <--- this throws an exception
...}

catche(exception $e)
{
$a->var1; <--- is empty ?!?!

}

The code is more complex but the idea is this.
it is possible?
what do you think?
Thankyou in advance,
Mario.
When I run th following code it works as expected, echo'ing "baz":

class Foo {
public $x;

public function bar() {
throw new Exception();
}
}

$f = new Foo();

try {
$f->x = 'baz';
$f->bar(); //this throws an exception
} catch (Exception $e) {
echo $f->x; //this correctly prints "baz"
}

May 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: rvm | last post by:
I do not understand why the following code will not compile. However, if I change the function getElem() in class MyCollection such that it returns an iElement (instead of MyElement), it compiles...
4
by: mchoya | last post by:
I'm so frustrated. I'm beginning school next week and I have been working on a simple program for several days now without being able to complete it. (Though I have brushed up on a lot of C++...
2
by: Paul Drummond | last post by:
Hi all, I am developing software for Linux Redhat9 and I have noticed some very strange behaviour when throwing exceptions within a shared library. All our exceptions are derived from...
0
by: sqcliu | last post by:
I encounter a strange problem using platform invoke using C#. The senario is this: I have a dll which uses a 3rd party static link library (lib). Inside the lib, there are some C structures...
0
by: Daniel Sélen Secches | last post by:
I found a good class to do a simple FTP. Very good.... I'm posting it with the message, i hope it helps someone ============================================================== Imports...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
11
by: D | last post by:
I have a winforms app that I'm reading some records from a datareader and writing them out to a file like so SqlDataReader dataReader = sqlCommand.ExecuteReader(); TextWriter textWriter = new...
2
by: ELINTPimp | last post by:
Hello all, Have a really interesting problem (at least to me) with my upload_file() function. I have it working now, with a bit of a work around, but would like to know what everyone thinks in...
3
by: Michael Schöller | last post by:
Hello, First of all english is not my natural language so please fogive me some bad mistakes in gramatic and use of some vocables :). I have a great problem here. Well I will not use it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.