Using LogTypes, Identify the type of exception caught before it's thrown, so i can compile a default message depending on what exception/error caught?

I want to identify the type of exception being caught before it gets displayed on the Unity UI canvas.

If for example, the caught exception is a 403. This will probably come with a long extended stack trace message but what i’d like to do, is take that message and only display a text, to the user.

Error message: 403 Forbidden.

I need a way to identify the error/exception for what it is, then I can execute what i need but i am not sure what I can use, to CHECK if it’s THIS or THAT. I’m not sure how to identify the error/exception. Is there something build into Unity that I can use?

I’d appreciate any help, from someone who knows or has experience in this already.

Thanks,

My code is as follows:

void Awake()
{
  Application.logMessageReceived += LogCaughtException;
  DontDestroyOnLoad(gameObject);
}

public void Start()
{
  throw new Exception("THIS IS MY TEST EXCEPTION");
}

private void LogCaughtException(string condition, string stackTrace, LogType type)
{
  switch (type)
  {
      case LogType.Warning:
          // Handle your warning logic here
          break;
      case LogType.Error:
          // Handle your error logic here
          break;
      case LogType.Exception:
          // Handle your exception logic here
            break;
        default:
            // Handle other logs here
            break;
    }
}