Add wrapping function to improve MemoryError message