Added SDL Error function to reduce code redundancy