Creates an error message with full error details:
- If the error is an exception, creates a message that includes the full
stack trace.
- If the error is an object that defines __toString(), creates a
message by casting the error to a string.
- If the error is not an object, casts the error to a string.
- Otherwise, cerates a generic error message indicating the class type.
In all cases, the error message is escaped for use in HTML.