Ibrahima Khalil Ibrahima Khalil - 1 year ago 518
Python Question

raise exception wave python

I use the wave module
for example .

import wave
origAudio = wave.open("son.wav",'r')

get output

raise Error, 'file does not start with RIFF id'
wave.Error: file does not start with RIFF id

I know the file is not good,but I want to raise this exception or this error

Answer Source

If you wish to continue after an expection has been raised you must catch it:

 import wave
   origAudio = wave.open("son.wav",'r')
 except wave.Error as e:
   # if you get here it means an error happende, maybe you should warn the user
   # but doing pass will silently ignore it
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download