n_v_isaev
12 years agoOccasional Contributor
Exclusion from another unit
I use the TC 9 and Jscript
I need to catch exceptions when creating objects
"Stop on exceptions" and "Error dialog" in my project settings is disabled
Example:
Unit1:
function Class1(){
throw new Error(-1,'error');
}
Unit2:
//USEUNIT Unit1
function test1(){
try {
Unit1.Class1(); // it works
Log.Message('need stored');
}
catch (err){
Log.Message('catch');
}
}
function test2(){
try {
var object_of_Class1 = new Unit1.Class1(); // It does not work
Log.Message('need stored');
}
catch (err){
Log.Message('catch');
}
}
In test1 all good
In test2 exception is not caught.
How can I catch the exceptions in test2 case?
I need to catch exceptions when creating objects
"Stop on exceptions" and "Error dialog" in my project settings is disabled
Example:
Unit1:
function Class1(){
throw new Error(-1,'error');
}
Unit2:
//USEUNIT Unit1
function test1(){
try {
Unit1.Class1(); // it works
Log.Message('need stored');
}
catch (err){
Log.Message('catch');
}
}
function test2(){
try {
var object_of_Class1 = new Unit1.Class1(); // It does not work
Log.Message('need stored');
}
catch (err){
Log.Message('catch');
}
}
In test1 all good
In test2 exception is not caught.
How can I catch the exceptions in test2 case?
- In my TC (9.1) your code works well, i have the exception caught in test2.
I've adapted the Class1 like that:
function Class1()
{
try {
throw new Error('error');
}
finally {
}
}