({{, (RefLink[MessageList, paclet:ref/MessageList])[n]
is a global object assigned to be a list of the names of messages generated during the processing of the n(^th) input line. }})

OpenersNotesSection(Spacer1)Details

Only messages that are actually output are included in the list (RefLink[MessageList, paclet:ref/MessageList])[n].

The message names in the list are wrapped with (RefLink[HoldForm, paclet:ref/HoldForm]).

(RefLink[MessageList, paclet:ref/MessageList])[n] includes messages generated both by built-in functions and by explicit invocations of (RefLink[Message, paclet:ref/Message]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Get any messages that were generated by the previous output:

LinearSolve[{{0}},{1}]

MessageList[-1]

There were no messages produced in the previous command:

MessageList[-1]

Now the command that gave the message is the third previous command:

MessageList[-3]

Get a list of all the messages that were generated in a session:

Map[MessageList,Range[$Line - 1]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[$MessageList, paclet:ref/$MessageList])  ▪  (RefLink[Check, paclet:ref/Check])  ▪  (RefLink[Message, paclet:ref/Message])  ▪  (RefLink[MessageName, paclet:ref/MessageName])  ▪  (RefLink[Out, paclet:ref/Out])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Messages, paclet:tutorial/Messages])}, {▪(RefLinkPlain[The Main Loop, paclet:tutorial/TheMainLoop])}, {▪(RefLinkPlain[Wolfram System Sessions, paclet:tutorial/WolframSystemSessions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Wolfram System Session History, paclet:guide/WolframSystemSessionHistory])}, {▪(RefLinkPlain[Messages, paclet:guide/Messages])}})}})