Member Avatar

Hi guys, I have a question about error handling. Still working on the addition application and now that I've learned what are the correct exceptions to handle I'm not sure what to do when I've established that the my inputs are all valid and print my result. Let's have a look at the calculator class again: package my.vaadin.project.exceptionTest; import java.awt.Component; import java.util.InputMismatchException; import com.vaadin.server.Page; import com.vaadin.shared.Position; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.Notification; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; import com.vaadin.event.Action; public class Calculation extends CustomComponent{ final VerticalLayout vl = new VerticalLayout(); final TextField dividend = new TextField(); final TextField divisor …

Member Avatar
0
71
Member Avatar

I have a function that does certain checks, if the the checks fail, it will add values to a dict, i.e: outstanding = {} sims = [_sim for _sim in self.context.sims if unicode(_sim.iccid)] # for sim in [_sim for _sim in self.context.sims if unicode(_sim.iccid)]: print sims count = len(sims) if count > 250: outstanding["pack.maximum"] = count if count < 5: outstanding["pack.minimum"] = count If these checks fail I raise an exception: if outstanding: raise HTTPInternalServerError(outstanding) This will raise an error on my template, I handle with ajax error handler: error: function(jqXHR, textStatus, errorThrown) { console.log(jqXHR); hide_spinner(); show_error(1,"There was an error …

0
10
Member Avatar

Hi, I'm trying to teach myself the Python language with the Google Python class ([url]http://code.google.com/edu/languages/google-python-class/set-up.html[/url]). With the exercise 'wordcount' I get a Traceback error (with the main function and sys.exit(1) function). Even with the solution script (as displayed here). Does anyone recognize this problem and can some one tell me what I'm missing here? wordcount gives the following [B]output:[/B] usage: ./wordcount.py {--count | --topcount} file Traceback (most recent call last): File "F:\Science\google-python-exercises\basic\solution\wordcount.py", line 114, in <module> main() File "F:\Science\google-python-exercises\basic\solution\wordcount.py", line 101, in main sys.exit(1) SystemExit: 1 [B]The code:[/B] [CODE] import sys def word_count_dict(filename): """Returns a word/count dict for this filename.""" …

Member Avatar
0
16
Member Avatar

I'm trying to find a record in a csv file in a nested stucture: for elem in lstLine[1:]: for item in open(fname): lstData = item.rstrip('\n').split(';') andexfield = lstData[0] if andexfield == elem: do bladibla Now I want ot add error handling: if no record in fname is found where andexfield == elem print "Error, no andexfield in fname" Can I do this with "try" ? Any help is much appreciated.

Member Avatar
0
5
Member Avatar

Dear enlighted ones. I happen to try to finsh a kind of a function library that my Main program can utilize. As of now, Everything work great... but. I would like to implement some kind of error handling. The way I do this also work, but the error is generated so that the procedure detecting the error is listed when Delphi breaks execution. Is there some way of implementing something so that the Break shows the line in main program instead? It is important to me to make descriptive error messages that can be used to solve problem. [CODE] //From …

Member Avatar
0
4
Member Avatar

I am handling a wordpress website for a client. It has around 4000 '404 errors'. I am thinking of redirecting it to the home page. But if I redirect, Google should not think that I am duplicating (though I am not doing). The other option is that I can request Google not to crawl the web pages that are '404 errors'. This '404 error' is due to the forum, which was linked to the website. I request forum members valid suggestion / advice on solving this issue.

Member Avatar
0
4
Member Avatar

[CODE]#!/usr/bin/python import smtplib sender = 'from@fromdomain.com' receivers = ['to@todomain.com'] message = """From: From Person <from@fromdomain.com> To: To Person <to@todomain.com> Subject: SMTP e-mail test This is a test e-mail message. """ try: smtpObj = smtplib.SMTP('smtp.gmail.com') smtpObj.sendmail(sender, receivers, message) print "Successfully sent email" except smtplib.SMTPException: print "Error: unable to send email" [/CODE] I get the following error when I try to run the script. Traceback (most recent call last): File "<string>", line 244, in run_nodebug File "C:\Python Rules\scripts\module4.py", line 16, in ? smtpObj = smtplib.SMTP('smtp.gmail.com') File "C:\Python23\Lib\smtplib.py", line 240, in __init__ (code, msg) = self.connect(host, port) File "C:\Python23\Lib\smtplib.py", line 303, in connect …

Member Avatar
0
4
Member Avatar

I can't decide which route to take when there's a problem. Let me set the scene, User_A creates a recipe, all other users can read it but they cannot modify it. In the edit recipe page, which is accessed via: [INDENT]edit_recipe.php?id={id}[/INDENT] If the user changes the id parameter to a recipe ID that they do not own then they are going to be denied access, here are the two options I can't decide between: [INDENT]a) Send them to the search page, to search for a recipe - even though it exists. b) Send them to a permissions denied page.[/INDENT] [B]Things …

Member Avatar
0
3

The End.