Manually Pass Test Case Based on Specific Caught Exception

We have a pipeline in place that runs a bunch of test cases against Sauce Labs devices every night. Often times, a device (iOS or Android) is unavailable at the time our pipeline runs because it is in use by someone else.

Right now, this generates an exception and fails our test case with the following exception in the logs:
errorId: ef4a9e01-f6ba-4d4d-a46f-dffa69200216 - Unable to allocate device within 900000ms or 3 tries. This can happen if there were no available devices within the time or your plan's max concurrent test run is not corresponding to your usage Detailed Info: Unable to find available device within 900000ms Build info: SOMEADDITIONALINFOHERE....

Does anyone have a nice approach for catching this exception type and manually making sure it doesn’t register as failed, since we don’t want this specific error type to break our pipeline.
Something like catching based on text match or something similar?

Something like…


// Test case steps

try {

  // your problem test case step here

} catch(Exception e) {
  if(e.message != "The exact exception message here") {
    throw e
  }
}

// The rest of your test case steps here