Ibrahima Khalil Ibrahima Khalil - 5 months ago 80
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


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