Add error type for write method