Should Try catch work during debug

Here is the code…

[code] Try
section = “Question”
cnt_Question1.txtAr_Question.text = Session.Project.Value(“rsrchPlan_Question”)
section = “Hypothesis”
cnt_Hypothesis1.txtAr_Hypothesis.text = Session.Project.Value(“rsrchPlan_Hypothesis”)
section = “Equipment”
cnt_Method1.cnt_Materials1.txtAr_Materials.Text = Session.Project.Value(“rsrchPlan_Equipment”)
section = “Method”
cnt_Method1.cnt_Proceedures1.txtAr_Procedures.Text = Session.Project.Value(“rsrchPlan_Method”)
section = “DataAnalysis”
cnt_Method1.cnt_Analysis1.txtAr_Analysis.text = Session.Project.Value(“rsrchPlan_DataAnalysis”)
section = “Bibliography”
cnt_Bibliography1.txtAr_Bibliography.Text = session.Project.Value(“rsrchPlan_Bibliograpy”)

Catch e As RunTimeException
Dim msg As String = “The system has detected a problem preventing editing of your on line research plan. The problem is most likely due to a poorly encoded special character in the “+section+” section of your research plan.”
ErrorMsg (“Global_LoadStudentProject”,e,msg)

End Try[/code]

I need to catch this error until I can find a fix for the problem. I am working in debug mode and want to make sure the catch is working properly and the message looks good before I build and deploy it, but it’s not catching the error. The error is…

Shouldn’t it be catching this error?

The error is generated when one of the sections contains things like a bullet list that has been copy and pasted into a xojo web page by the student from GoogleDocs. It gets saved to the databaase without any problem. When the student later returned to their Xojo registration Xojo the site would crash when the section was retrieved from the database at log in. I was able to fix this log in problem, and now the section gets loaded to the Session.Project dictionary without a problem. I just now discoverd that apparently the section continues to cause a crash when an attempt is made to display the section in a Xojo web page. I need to fix this, but first I need the try catch to work.

If you have Project->Break on Exceptions checked, then exceptions drop into the debugger regardless of whether they are caught.

Using the Debugger

Yes I had Project->Break on Exception checked, but the problem is that the error message is being thrown as if it is a built web app. It is not dropping into the debugger. I unchecked Project->Break and it still does not catch the error and throws the “This application has encountered an error and cannot continue” error dialog.

I have other places where I am using Try and they work fine with or without Project->Break checked. They either drop into the debugger and then run the catch or just run the catch. In this case I only get the “This application has encountered an error and cannot continue” error dialog.

Which means apparently the exception you expect simply does not occur…

At first glance, I do not see how your code could raise an exception. It simply affects values to strings. In general, strings don’t raise exceptions when the encoding is wrong. They simply show <?> lozenges.

Maybe you want instead to use a block of Select case or if then else.

With Break on exception checked I get the black bordered dialog with the Do Not Send and Send buttons. I believe it’s an Unexpected End of File error. I have included the entire message below.

It might be useful to know that I can manually fix the bad section if I go to the database and copy the text out, paste it into TextEdit, then copy the text without modification out of TextEdit back into the database. The registration then works flawlessly in Xojo. The bad section in the error description is the last Xojo.controls[‘FvTQClfk’].setValue which is a bibliography copied from GoogleDocs.

[quote]Could not execute returned javascript: Unexpected EOF
Source: Xojo.controls[‘ByJxJi9P’].setVisible(false);
Xojo.controls[‘ByJxJi9P’].refresh();
Xojo.controls[‘ZOXupdch’].setVisible(false);
Xojo.controls[‘ZOXupdch’].refresh();
Xojo.controls[‘GmjOn3ML’].setVisible(false);
Xojo.controls[‘GmjOn3ML’].refresh();
Xojo.controls[‘TQlQIikW’].setVisible(false);
Xojo.controls[‘TQlQIikW’].refresh();
Xojo.controls[‘W4eUlUCH’].setVisible(false);
Xojo.controls[‘W4eUlUCH’].refresh();
Xojo.controls[‘RBaUb5RJ’].setVisible(false);
Xojo.controls[‘RBaUb5RJ’].refresh();
Xojo.controls[‘SHBHPfri’].setVisible(false);
Xojo.controls[‘BHkzcB9x’].setVisible(true);
Xojo.refreshControl(‘QNaqqUXH’);
Xojo.refreshControl(‘IERT70Z7’);
Xojo.refreshControl(‘IaB21ew6’);
Xojo.refreshControl(‘X8IgMDkE’);
Xojo.refreshControl(‘DZ1UhGNh’);
Xojo.refreshControl(‘OadfPMSW’);
Xojo.refreshControl(‘DIg0wA4A’);
Xojo.refreshControl(‘P01W9gTl’);
Xojo.refreshControl(‘M3gRrEiE’);
Xojo.refreshControl(‘HvD119KP’);
Xojo.refreshControl(‘UUW4uOAQ’);
Xojo.refreshControl(‘Olo3vyDA’);
Xojo.refreshControl(‘ZUjkm0Vw’);
Xojo.refreshControl(‘UY3X59GB’);
Xojo.refreshControl(‘IhYNz3zS’);
Xojo.refreshControl(‘QwgWJJU0’);
Xojo.refreshControl(‘Z4CLdvTm’);
Xojo.refreshControl(‘Z9XXZjzR’);
Xojo.refreshControl(‘QNb2Mrro’);
Xojo.refreshControl(‘NR4esXAi’);
Xojo.refreshControl(‘B4iFnOzi’);
Xojo.refreshControl(‘HHiFy0MD’);
Xojo.refreshControl(‘OqvaYeCT’);
Xojo.refreshControl(‘ObgLPDcb’);
Xojo.refreshControl(‘QPh5o0GE’);
Xojo.refreshControl(‘Ecw99YOK’);
Xojo.refreshControl(‘EY2d9kWs’);
Xojo.refreshControl(‘ThQ9kx3r’);
Xojo.refreshControl(‘UkSPYbAa’);
Xojo.refreshControl(‘SUH8Y5nD’);
Xojo.refreshControl(‘Nyiyw0rk’);
Xojo.refreshControl(‘UEhfNEGK’);
Xojo.refreshControl(‘Lr6NWeGL’);
Xojo.refreshControl(‘TrqSCCh3’);
Xojo.refreshControl(‘JfezqwKr’);
Xojo.refreshControl(‘Rb4uZiIm’);
Xojo.refreshControl(‘I69usfTW’);
Xojo.refreshControl(‘Guukh8z3’);
Xojo.refreshControl(‘J1Bhvd3p’);
Xojo.refreshControl(‘DKTOHvab’);
Xojo.refreshControl(‘YRMG8qyy’);
Xojo.refreshControl(‘FXfSN81w’);
Xojo.refreshControl(‘UmhOZAkv’);
Xojo.refreshControl(‘Nl8A7657’);
Xojo.refreshControl(‘OrFNZWhI’);
Xojo.refreshControl(‘NtfTtSeU’);
Xojo.refreshControl(‘Qpaj08DL’);
Xojo.refreshControl(‘GzhiSsk6’);
Xojo.refreshControl(‘U4uCbGke’);
Xojo.refreshControl(‘OpeLEUiS’);
Xojo.refreshControl(‘Rm4xhnHL’);
Xojo.refreshControl(‘K3vgQXwm’);
Xojo.refreshControl(‘Xt5BW1kv’);
Xojo.refreshControl(‘Oq6tUZWD’);
Xojo.refreshControl(‘Qno3WZ9p’);
Xojo.refreshControl(‘FvTQClfk’);
Xojo.refreshControl(‘MIhf9dU3’);
Xojo.refreshControl(‘Q0GTOsIN’);
Xojo.refreshControl(‘YYsaF1jS’);
Xojo.refreshControl(‘P9ZZi6Cg’);
Xojo.refreshControl(‘N1OZUT2h’);
Xojo.refreshControl(‘GD3WN3hN’);
Xojo.refreshControl(‘W6aOViVb’);
Xojo.refreshControl(‘J8i5bFLj’);
Xojo.refreshControl(‘Mt0a6KrY’);
Xojo.controls[‘Olo3vyDA’].setValue(true,true);
Xojo.controls[‘Olo3vyDA’].setStyle(‘Notes_Normal_Italic_Red’);
Xojo.controls[‘Olo3vyDA’].refresh();
Xojo.controls[‘IhYNz3zS’].setValue(“Hawaii has the highest electricity costs in the nation, averaging 34 cents per kw/h. Native Hawaiians living in rural parts of Hawai?i Island, that are not on the electrical power grid, must resort to using propane as their primary energy source. Solar power and wind power are not economical options for this community due to their remote locations. The purpose of this project is to create an eco-friendly portable device made of peltier modules that would produce a sustainable source of energy. After creating two copper boxes and placing waters at different temperatures in them, the peltier modules in between the boxes generated a variation of voltages. Preliminary tests of this device show that when the difference in temperature is 80 degrees Celsius then the device will sustain one volt. My design plan for this project will include the creation of an insulated system of peltier modules in series and this will be tested on a future model house. Fresnel glass lens on the roof will heat a water pipe from the house, which will lead into the peltier system. A second pipe containing ambient temperatures will also lead into the peltier system acting as the cold water pipe. The difference in these temperatures will result in an electricity output that will power the lights in the house. This prototype can be scaled up to a normal sized house in the hope of creating a clean energy source for Native Hawaiians living in rural areas.”);
Xojo.controls[‘NR4esXAi’].setValue(’<a href=“http://192.168.1.100/ResearchPlanExample1.pdf” target="_blank">Sample 1’);
Xojo.controls[‘B4iFnOzi’].setValue(’<a href=“http://192.168.1.100/ResearchPlanExample2.pdf” target="_blank">Sample 2’);
Xojo.controls[‘HHiFy0MD’].setValue(’<a href=“http://192.168.1.100/ResearchPlanExample3.pdf” target="_blank">Sample 3’);
Xojo.controls[‘QPh5o0GE’].setValue(“I hypothesized that when the temperature difference is greater then the voltage output would also be greater. I also hypothesized that as the temperatures reach ambient then the voltage output will also decrease at a proportional rate.”);
Xojo.controls[‘DKTOHvab’].setValue(“•\t2 ft by 8 ft Copper Sheet (16-oz)
•\t3 ft by 4 ft by 5/8 inch Plexi Glass Sheet
•\t3 ft by 12 ft by 1 inch Foam Sheet
•\tFive Piece Soldering Torch ?
•\tFlux ?
•\tSolder ?
•\tPeltier Modules (6) (40mm x 40mm x 15mm) ?
•\tPlywood 4ft by 8ft by 1 inch ?
•\tPhilips Bugle-Head Coarse Thread Sharp Point Polymer Coated Exterior Screws (pack) ?
•\t10 LED single lights
•\tElectric Wiring 250 ft ?
•\t3/4 Inch x 100 ft Blue PEX Pipe ?
•\t2 Light Water Pump
•\t5 Pack Fresnel Glass 7in by 11in
•\tOne double solar cell 1in by 2in”);
Xojo.controls[‘FvTQClfk’].setValue(“Cahaya, Adam B.; Tretiakov, Oleg A.; Bauer, G. E. W. “Spin Seebeck Power Conversion.”? 2015.
Cui INC. “Peltier Application Notes.” http://www.cui.com/catalog/resource/peltier-app-note.pdf. 2015.
Flipse, J.; Dejene, F. K.; Wagenaar, D.; Bauer, G. E. W.; Ben Youssef, J.; Van Wees, B. J. “Observation of the Spin Peltier Effect.”?Effect. 2015.
Juarez-Acosta, Isaac; Olivares-Robles, Miguel A.; Bosu, Subrojati; Sakuraba, Yuya; Kubota, Takahide; Takahashi, Saburo; Takanashi, Koki; Bauer, Gerrit E. W. “Modelling of the Peltier Effect in Magnetic Multilayers.”?Effect in Magnetic Multilayers. 2015.
López, Rosa; Hwang, Sun-Yong; Sánchez, David. “Thermoelectric Effects in Quantum Hall Systems beyond Linear Response.”?Quantum Hall Systems beyond Linear Response?. 2015.”);[/quote]

Forgot to say that I get the same thing without Break on exception checked.

It appears you are not getting a Xojo exception, but are getting a lower-level Javascript error. There’s not really anything you can do to catch that. Perhaps you could return True in App.UnhandledException to ignore the error, but that is probably not the safest thing to do.

Best would be to correct the text that is causing the Javascript error before you try to assign it to the UI.

[quote=252750:@John Baughman]The error is…

Could not execute returned javascript: Unexpected EOF

Shouldn’t it be catching this error?[/quote]
No, it should not. That’s a browser error, not an exception.

Thanks Pau & Tim. That explains why the Try Catch is not working. Wish I could keep the students from using GoogleDocs.

The database is encoding UTF8 and I am calling data = defineEncoding(data, encodings.UTF8) in Xojo on receipt.

Do you know if there is anything more in Xojo that I can do to clean up these sections in the project dictionary? I have run out of options in the database.

I am sending the project dicstionary as inputed by the student, pasted from GoogleDocs, with the following…

Dim get As String = "output=xml&site=xojo" get = get + "&districtFair=true" DIM socket1 As New HTTPSocket socket1.SetFormData(session.Project) DIM data As string = socket1.Post("http://"+Host+"/chaos/update_Project?"+get, 30)

Is there anything more I can do the the research plan sections to clean it up before I send the dictionary to the database?

Thanks,

Instead of TextEdit, you could try putting the data into a WebTextArea.Text, then get it back.

If it works, place the TextArea off view ( Top at -500 or something like that) and use it to clean your input.

Would converting HTML entities help or will that just confuse Xojo when it comes time to push it to the browser?

Yeah, don’t do that. We do that behind the scenes when you set the field’s value.

Do you DefineEncoding when you pull it back from the database? That’s the only time it matters.