def METHOD_NAME(self):
    class MyValueError(ValueError):
        pass
    @torch.jit.script
    def fn():
        raise MyValueError("test custom exception")
    with self.assertRaisesRegex(torch.jit.Error, "jit.test_exception.MyValueError: test custom exception"):
        fn()