adding error handling

some callbacks will now have to pass and accept an extra 'err' argument