If you are asking a question about an error or code, it needs to be in there as text otherwise it won't be searchable for other users.
I think screenshots of errors and code can be useful but only as supplementary information to the actual code/error as text. I find it helpful to see the actual error window sometimes as it helps me remember where I've seen this before or where exactly the error is coming from.
Images and screenshots can be a nice addition to a post, but please make sure the post is still clear and useful without them. If you post images of code or error messages make sure you also copy and paste or type the actual code/message into the post directly.
In rewording like this it also frames the issue positively (do this) rather than negatively (don't do this).