When I clicked the button, I got the error "ReferenceError: function is not defined".

In this sentence, I am telling somebody that when I click a button in a software application, I get an error. The remaining part of the sentence, i.e. "ReferenceError: function is not defined", describes the error/tells what exactly the error is.

Likewise, in the following sentence, I am telling that he used a(the?) proverb, and then telling what the proverb was.

He used the proverb "A rolling stone gathers no mass", which described the gist of the story perfectly.

The question is that in sentences like these, when we talk about a thing, and then immediately describe what the thing is, is there any punctuation required between the first piece of information, and the description of the thing we have just talked about (like a colon)?

When I clicked the button, I got the error : "ReferenceError: function is not defined".

How would you write these sentences correctly in formal English?

  • 1
    Would it be correct to rephrase your header question as "Do I need to set of the break between an independent clause in quotation marks and an independent clause not in quotation marks with additional punctuation?" I'm trying to think of a way of reworking your current header so that future site visitors searching for an answer to the same question you have will be able to find this page.
    – Sven Yargs
    Jan 20, 2016 at 18:13
  • @SvenYargs Yes sure, and thank you. At the time I wrote the question, I could only think about it vaguely, and it wasn't that clear in my mind. I would also worry about the length of the question, as I am not sure if that long a title can be written, and secondly, will somebody read that long a title. If you think those concerns are not something to worry about, please lemme know. I will edit the title, and it will also help me in the future. Thank you again.
    – Solace
    Jan 20, 2016 at 20:58
  • 1
    I suggest "Punctuating the transition in a sentence between an independent clause and a descriptive quotation." I think that's not too long for a header, and it seems like a pretty accurate description of your question.
    – Sven Yargs
    Jan 21, 2016 at 17:23

2 Answers 2


Punctuation is a matter of style, and as such, you should be guided by your manual of style. I use the Chicago Manual of Style, which addresses your construct, the appositive. An appositive is a noun phrase (like the error message in your post) that follows and renames a noun (the word "error" in your post). Appositives that merely add supplementary or explanatory information are set off by commas:

Sometimes when I click a button, I get an error message, a string of text explaining what went wrong.

In this case, the italicized appositive renames an error message as a type of text string. Appositives that define the word they follow are called restrictive appositives, and these are not set off by commas:

When I clicked the button, I got the error message "ReferenceError: function is not defined".

CMS advises that colons be used in special circumstances -- before a list that comes after the word following or to separate text that provides an example or is conclusory. So a colon would be inapt, and in your particular case would clash with the colon after "ReferenceError".


This is a question of style. However, in general, such a sentence requires no punctuation between the word "error" and the error itself when set apart in quotation marks as you have done. This applies the same grammar I used when I didn't put any punctuation around the word "error" in the last sentence or this one.

Punctuation around quoted speech or phrases depends on how it fits into the rest of your text. If a quoted word or phrase fits into the flow of your sentence without a break or pause, then a comma may not be necessary:

The phrase "lovely, dark and deep" begins to suggest ominous overtones.

This applies the same principle you would apply when saying, for example, that you received the HTTP error "404 not found."

Following a form of to say, however, you'll almost always need a comma:

My father always said, "Be careful what you wish for."





Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.