The actual Problem
The problem I am trying to solve is that a user may not provide enough information on a message (discord). To then get all of the necessary data the user is prompted to react to a bot message. There are 3 stages of that bot message, "InitialPrompt", "TimeoutWarning" and "TimeoutSuccess(TicketFailure)".
What I wanted the solution to be
With the way I've written my code there is no way to abort the timeout after it has been initialized. I thought that throwing an error would stop the execution of a function. I guess that doesn't happen because async calls get queued up instead of being ran line by line.
Is there a way to do this without adding a boolean and checking infront of each function call?
The solution that I could come up with
const interPtr = {interrupted : false};
interruptSignal(interPtr);
if(interPtr.interrupted) return;
console.log("...");
...
The actual code
(async () => {
  const sleep = async time => new Promise(resolve => setTimeout(resolve, time));
  const interruptSignal = () => new Promise(async (res, rej) => {
    console.log("interruptStarted")
    await sleep(2000);
    console.log("interruptRan");
    throw "Interrupted"
  });
  
  const timeOutHandler = async () => {
    interruptSignal();
    console.log("TimeoutStarted")
    await sleep(5000);
    console.log("TimeoutWarning")
    await sleep(5000);
    console.log("TimeoutSuccess->TicketFailure")
  };
  try {
    await timeOutHandler();
  } catch (e) {
    console.log(e);
  }
  
})()
 
    