I think I have misunderstood the question. I thought OP was asking about an otherwise well-written question which included badly formatted error message, for which the following answers. If the question itself was nothing more than a badly formatted error message (e.g. "I am getting this error ... pls help") then absolutely burn it with fire and follow the advice in this answer instead.
This comes up time and time again where lower-rep users who do not have sufficient privileges cannot perform an action they feel is best.
In this situation, you did the right thing. You tried to edit the post, but your edit wasn't accepted by the system as it was too insufficient. If there is truly NOTHING further to edit, then cancel the edit, and leave a comment on the post. The comment will let the author know there is a formatting problem, but it also lets other community members know, and someone else may fix it up for you.
- Yes, leave a comment by all means.
- If there's nothing further to improve in the post, I agree with you to not edit it. 1
- Do NOT flag for moderation attention. This is simply one of those things where unfortunately you cannot make a change that would be better for the community.
Hope that your comment is actioned by either the OP or another community member. You are free to downvote the question if you feel the badly formatted error takes away from the question.
1 That said, for an error message, you could probably easily add "This is the error I'm getting", or if something similar was added, you could modify it to "Here's the error".