Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #11865

try... except with unknown error types

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!news.astraweb.com!border2.a.newsrouter.astraweb.com!multikabel.net!newsfeed10.multikabel.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <Yingjie.Lin@mssm.edu>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'python,': 0.01; 'python': 0.08; 'either.': 0.09; 'subject:error': 0.10; 'users,': 0.13; 'better:': 0.16; 'occur.': 0.16; 'x-mailer:apple mail (2.1084)': 0.16; "doesn't": 0.22; 'correctly.': 0.24; 'specify': 0.24; 'expect': 0.25; 'tried': 0.26; 'print': 0.29; 'recognized': 0.30; 'situations': 0.30; 'error': 0.32; 'does': 0.32; 'anyone': 0.32; "can't": 0.33; 'there': 0.33; 'to:addr:python-list': 0.33; 'recognize': 0.34; 'try:': 0.34; 'thank': 0.35; 'certain': 0.35; 'charset:us-ascii': 0.36; 'skip:" 10': 0.36; 'example,': 0.37; 'statements': 0.37; 'response': 0.37; 'using': 0.37; 'put': 0.37; 'but': 0.37; 'received:org': 0.38; 'too,': 0.38; 'should': 0.38; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'might': 0.40; 'where': 0.40; 'you.': 0.62; 'subject:... ': 0.84; 'subject:types': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=mssm.edu; h=date : from : subject : to : message-id : mime-version : content-type : content-transfer-encoding; s=mail; bh=aMgyDZe878vU5KwppoBBV8okWo/3aIugeTQFFloTU2s=; b=U+O+/v/+0dBz9AWjF/e3mwkoPdNhSPms5nUjLYlQkln7ZRrPS8ePUimqcD6MvpsjaRiu X4gedEB+bZqAJi9zVPmSQ5VffiyixqFl3QSo+eAAjSg8HrcOSCUAG8hD7qxYhuodBFLr lEQuV+FAtLXPgNKvM158pgkGRWZYFwic7jb90iy+4W1zkCLieUUVUxMegW0+UuSBIZbJ tcW27ABuKAPLJm+VPbi8ADnhtdEp9/W5emktz/wky6H+pCuxN5Z1tAzI/Fhix0EfOxlm 57z7q0hiR42wmEnsc/2gFw++9/7Eli8wPsOqtvDd4J14pUaHj1HBPMxX3Kdx8Om8UErb 2g==
Date Fri, 19 Aug 2011 15:09:12 -0400
From Yingjie Lin <Yingjie.Lin@mssm.edu>
Subject try... except with unknown error types
To python-list@python.org
MIME-version 1.0
X-Mailer Apple Mail (2.1084)
Content-type text/plain; charset=us-ascii
Content-transfer-encoding 7BIT
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:5.4.6813, 1.0.211, 0.0.0000 definitions=2011-08-19_07:2011-08-19, 2011-08-19, 1970-01-01 signatures=0
X-Proofpoint-Spam-Details rule=notspam policy=default score=1 spamscore=1 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=6.0.2-1012030000 definitions=main-1108190209
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.230.1313780957.27778.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1313780957 news.xs4all.nl 23915 [2001:888:2000:d::a6]:47858
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:11865

Show key headers only | View raw


Hi Python users,

I have been using try...except statements in the situations where I can expect a certain type of errors might occur. 
But  sometimes I don't exactly know the possible error types, or sometimes I just can't "spell" the error types correctly. 
For example, 

try:
	response = urlopen(urljoin(uri1, uri2))
except urllib2.HTTPError:
	print "URL does not exist!"

Though "urllib2.HTTPError" is the error type reported by Python, Python doesn't recognize it as an error type name. 
I tried using "HTTPError" alone too, but that's not recognized either.

Does anyone know what error type I should put after the except statement? or even better: is there a way not to specify
the error types? Thank you.


- Yingjie






Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

try... except with unknown error types Yingjie Lin <Yingjie.Lin@mssm.edu> - 2011-08-19 15:09 -0400
  Re: try... except with unknown error types John Gordon <gordon@panix.com> - 2011-08-19 19:14 +0000
    Re: try... except with unknown error types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-20 06:13 +1000
      Re: try... except with unknown error types John Gordon <gordon@panix.com> - 2011-08-19 20:24 +0000
        Re: try... except with unknown error types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-20 06:45 +1000
          Re: try... except with unknown error types Seebs <usenet-nospam@seebs.net> - 2011-08-20 05:46 +0000
        Re: try... except with unknown error types John Nagle <nagle@animats.com> - 2011-08-20 13:15 -0700
      Re: try... except with unknown error types Paul Rubin <no.email@nospam.invalid> - 2011-08-20 12:18 -0700
        Re: try... except with unknown error types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-21 06:14 +1000
          Re: try... except with unknown error types Paul Rubin <no.email@nospam.invalid> - 2011-08-21 11:26 -0700
            Re: try... except with unknown error types Chris Angelico <rosuav@gmail.com> - 2011-08-21 20:17 +0100
              Re: try... except with unknown error types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-22 10:30 +1000
                Re: try... except with unknown error types Chris Angelico <rosuav@gmail.com> - 2011-08-22 01:41 +0100
                Re: try... except with unknown error types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-22 14:01 +1000
                Re: try... except with unknown error types Paul Rubin <no.email@nospam.invalid> - 2011-08-23 00:21 -0700
                Re: try... except with unknown error types Chris Angelico <rosuav@gmail.com> - 2011-08-23 09:26 +0100
                Re: try... except with unknown error types gene heskett <gheskett@wdtv.com> - 2011-08-23 04:43 -0400
                Re: try... except with unknown error types Paul Rubin <no.email@nospam.invalid> - 2011-08-23 10:43 -0700
                Re: try... except with unknown error types Chris Angelico <rosuav@gmail.com> - 2011-08-23 10:07 +0100
                Re: try... except with unknown error types John Nagle <nagle@animats.com> - 2011-08-31 21:22 -0700
            Re: try... except with unknown error types Ethan Furman <ethan@stoneleaf.us> - 2011-08-21 12:22 -0700
            Re: try... except with unknown error types Terry Reedy <tjreedy@udel.edu> - 2011-08-21 15:52 -0400
              Re: try... except with unknown error types Chris Torek <nospam@torek.net> - 2011-08-31 21:01 +0000
                Re: try... except with unknown error types Stefan Krah <stefan-usenet@bytereef.org> - 2011-09-09 23:41 +0200
                Re: try... except with unknown error types Nobody <nobody@nowhere.com> - 2011-09-10 10:33 +0100
                Re: try... except with unknown error types Peter Otten <__peter__@web.de> - 2011-09-10 12:17 +0200
            Re: try... except with unknown error types Roy Smith <roy@panix.com> - 2011-08-21 17:14 -0400
            Re: try... except with unknown error types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-22 10:25 +1000
              Re: try... except with unknown error types Roy Smith <roy@panix.com> - 2011-08-21 22:09 -0400
            Re: try... except with unknown error types Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-08-23 18:33 +1000

csiph-web