Why does catch not return the error in this case? [duplicate]

Beginner who just got into Fetch API. I’m trying to console.log the error message that appears when someone attempts to fetch a file that doesn’t exist but it doesn’t work. It only. Can anyone please explain where I’m going wrong.

document.getElementById('button1').addEventListener('click', getText);

//getText function
function getText() {
    //fetching file that doesn't exist to produce the error
        return response.text();
    })//what's supposed to happen when the error is caught
%d bloggers like this: