Tenancy-aware custom error page

One approach is to have a plug that “loads” the tenant and sets the path to tenant-specific styling (e.g. CSS, values for tennnt name, etc.) This is pretty common in multi-tenant applications.

Then use ErrorView[1] to implement custom error pages which use those values to customize the error pages.

That way there is no additional loading of data, DB checks, etc in the error template.

To avoid a strange loop between “can’t find that tenant” and an error page that relies on a tenant being found, I tend to use a redirect to a known generic landing page specifically for that case in the “load the tenant” plug.

[1] If using Phoenix; replace with the equivalent handler in whatever framework you are using.