Refactor library errors