anyaudio / anyaudio-server

:musical_note: Simple server to search youtube and give direct audio download and stream links
91 stars 19 forks source link

Proper error handling and reporting #60

Closed singhpratyush closed 6 years ago

singhpratyush commented 8 years ago

Currently any server error returns an 500 with message Some error occurred. Proper error handling and reporting needs to take place. Different child classes of Exception can be kept in core/utils.py which will be used to track different problems as they occur.

def something():
    ...
    try:
        try:
            do_complex_operation_1()
        except MyException1:
            raise MyException2()
        ...
        try:
            do_complex_operation_2()
        except MyException3:
            raise MyException4()
        ...
    except MyException2:
        user_message = 'Error in operation 1'
        ...
    except MyException4:
        user_message = 'Error in operation 2'
        ...
    ...
    return_dictionary{'userMessage'} = user_message

This can be used at different levels to precisely track the error.