error trapping...

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

error trapping...

#1

Postby t4nu » Fri Aug 12, 2016 9:56 am

Hi,
I try to do an error trap, when something classified as error happen, I invoke event.owner.adderrormessage, but the if after that error message displayed, then the user doing the allowable did, still that error come up.
What should I do to prevent that to happen?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Fri Aug 12, 2016 10:08 am

If you still get the error message, it means the error is still being generated by the script. It sounds like there's something wrong with your code, could you add it to this post.
0 x

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

#3

Postby t4nu » Fri Aug 12, 2016 4:38 pm

Here is the code:

The function below will try to add a new user and if the email registered is already exists it will trigger the error message. The problem is, even if the email is change to an absolutely new (never registered) email address, still the it assumed already exists.

Code: Select all

function RegisterNewUser()
{
	
	var lSuccess = true;
	var newReg = system.sequenceManager.sequence('APPLICANT');
	tables.APPLICANTUSER.insertRow();
	tables.APPLICANTUSER.EMAILADDRESS.value = fields.emailAddress.value;
	tables.APPLICANTUSER.REALNAME.value     = fields.RealName.value;
	tables.APPLICANTUSER.PASSWORD.value     = Transpose(fields.Password.value.trim());
	tables.APPLICANTUSER.APPLICANTID.value  = newReg;

	try
	{
	   tables.APPLICANTUSER.updateTable();
	}
	catch (ex)
	{
		lSuccess = false;
		controls.msgPanel.hidden = false;
		if (ex.javaException instanceof com.ebasetech.xi.exceptions.FormRuntimeException)
		   event.owner.addErrorMessage("Email address: " + fields.emailAddress.value + " is already registered!")
		else
 		   event.owner.addErrorMessage(ex.message);
	}

	if (lSuccess)
	{		
		SendConfirmationLink(newReg);
	}
	else
	{
	  event.owner.addErrorMessage("Unknown problem happen that prevent your data entered to the system.")
	}
}

Jon wrote:If you still get the error message, it means the error is still being generated by the script. It sounds like there's something wrong with your code, could you add it to this post.
[/code]
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#4

Postby Jon » Fri Aug 12, 2016 5:07 pm

Your code assumes that any failure in the updatetable() is a duplicate record, which it might not be. I suggest you add log(ex) or print(ex) to the catch clause so you can see exactly what is going wrong.
0 x

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

#5

Postby t4nu » Sun Aug 14, 2016 4:18 am

IC.
I changed the code and seems everything is fine now.
Thanks.
Jon wrote:Your code assumes that any failure in the updatetable() is a duplicate record, which it might not be. I suggest you add log(ex) or print(ex) to the catch clause so you can see exactly what is going wrong.
0 x


Who is online

Users browsing this forum: No registered users and 9 guests