I use Stan only occasionally so it is possible that what follows is a really trivial question. Apologies.

I am using three priors based on distributions with finite support, such as the beta distribution. Draws from each prior distribution are transformed into the parameters of a custom distribution that I have written.

The problem is that some combinations of draws from the three priors yield parameters for the custom distribution that are inconsistent with the data and an error is thrown.

What I want to happen in such cases is that the log likelihood is simply increased by zero and we move on to the next set of draws.

In a bit more detail I have three parameters:

```
parameters {
real<lower = 0, upper = 1> q1;
real<lower = 0, upper = 1> q2;
real<lower = 0, upper = 1> q3;
}
...
model {
// priors
q1 ~ beta(shape11, shape21);
q2 ~ beta(shape12, shape22);
q3 ~ beta(shape13, shape23);
...
}
```

where the `shape11, ..., shape23`

parameters are data.

The `q1,...,q3`

parameters are transformed to produce a parameter `mu`

of my custom distribution the code for which includes the quantity

```
log1p(y - mu)
```

where `y`

is the vector of observations.

The trouble is that depending on the observations some elements of `1 + y - mu`

can be negative which throws an error and terminates the run.

I think that what I need to know is how to amend my custom function so that when a negative element of `1 + y - mu`

occurs the value returned is 0.

In R I could do this using `tryCatch()`

but I don’t know of an equivalent feature in Stan.

```
type or paste code here
```