Refactor Session error handling