Add platform agnostic error handling