By the way, does this exception work? Also, it seems that raising BadRequest exception (and 400 http status code) is better than returning 502 Bad Gateway in case of bad js profile path. Changing it to BadRequest won't probably work as-is - I recall that these exceptions are raised in splash.pool.RenderPool.render and are not handled correctly if raised elsewhere - so you may either have to fix that or to move profile chacking code to an earlier stage.