I want to produce a table of contents using LaTeX like this image at which the table of contents list are all in capital:

So I wrote this LaTeX code:
%To make the sections in uppercase
\makeatletter
\patchcmd{\l@section}{#1}{\MakeUppercase{#1}}{}{}% Sections use UPPERCASE in ToC
\makeatother
And this produced a strange error:
I don't understand the meaning of this error and I don't know how to solve it.
Any help ?
Edit: Here is my complete code:
\documentclass{article}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\usepackage{tocloft,etoolbox}
%To make the sections in uppercase
\makeatletter
\patchcmd{\l@section}{#1}{\MakeUppercase{#1}}{}{}% Sections use UPPERCASE in ToC
\makeatother
\begin{document}
\renewcommand\thesection{\arabic{section}}
%\renewcommand\tableofcontents{\MakeUppercase{tableofcontents}}
%To change the name of table of contents
\renewcommand\contentsname{\textbf{Table of Contents}}
%\MakeUppercase{\tableofcontents}
\tableofcontents
\section{Introduction}
This is the first section.
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit. Etiam lobortisfacilisis sem. Nullam nec mi et
neque pharetra sollicitudin. Praesent imperdietmi nec ante.
Donec ullamcorper, felis non sodales...
\newpage
\section{Second Section}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Etiam lobortis facilisissem. Nullam nec mi et neque pharetra
sollicitudin. Praesent imperdiet mi necante...
\end{document}


hyperrefwhich is a very important piece of information that you did not mention in your question. This is why we always ask for a full but minimal example, such that we can see which class and minimal preamble you are using. – daleif Sep 27 '21 at 11:03\...namemacros. A lot of macros assume that\...namemacros are text with no formatting. – daleif Sep 27 '21 at 12:12hyperrefhas changed a bit since then. So I'm not sure if this is a good solution – daleif Sep 27 '21 at 12:13