diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2012-09-05 07:08:04 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2012-09-05 07:08:04 -0400 |
commit | 9db99205c88ba6c99173e9faf53b293ce6914325 (patch) | |
tree | cdf24397c0fa97c95c8d4ba684284b4244c05b30 /www/gps_report.cgi.in | |
parent | 3ea948ecb5422091fe470b9b445647e4c7570b6f (diff) | |
download | gpsd-9db99205c88ba6c99173e9faf53b293ce6914325.tar.gz |
Better error handling in the CGI.
Diffstat (limited to 'www/gps_report.cgi.in')
-rw-r--r-- | www/gps_report.cgi.in | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/www/gps_report.cgi.in b/www/gps_report.cgi.in index 7483b3d4..4b38a0d3 100644 --- a/www/gps_report.cgi.in +++ b/www/gps_report.cgi.in @@ -98,11 +98,15 @@ if hasRequiredElements(form) and form.getvalue("action") == "Send Report": msg = report.as_string() smtp = smtplib.SMTP(host=servaddr.split("@")[1]) smtp.set_debuglevel(1) - smtp.sendmail(servaddr, ["esr@thyrsus.com"], msg) - smtp.quit() - print "<H1>New device report accepted.</H1>\n" - print "<p>Your report on the %s %s was successfully recorded. Thanks for helping improve GPSD.\n" \ - % (form.getvalue('vendor'), form.getvalue('model')) + try: + smtp.sendmail(servaddr, ["esr@thyrsus.com"], msg) + smtp.quit() + print "<H1>New device report accepted.</H1>\n" + print "<p>Your report on the %s %s was successfully recorded. Thanks for helping improve GPSD.\n" \ + % (form.getvalue('vendor'), form.getvalue('model')) + except smtplib.SMTPSenderRefused, e: + print "<H1>Your submission failed.</H1>\n" + print "<p>The error code was %s: %s</p>" % (e.code, e.response) sys.exit(0) # Everything below here is page generation |