rhcarvalho

rhcarvalho

Tenancy-aware custom error page

I found How can I add a custom header to my error pages?, which showed me Plug.ErrorHandler — Plug v1.20.2.

The general advice is to keep error pages simple, independent of existing layouts, minimal dependencies, to avoid more errors when rendering the error page itself.

How do you approach custom error pages when each application tenant has their own branding? E.g. custom name, logo, color scheme.

My expectation would be to have a 404 page better-aligned with the current tenancy than, say, a 500 caused by a DB error.

Anyone aware of open-source Phoenix apps that fit that category as a source of inspiration?

Marked As Solved

aseigo

aseigo

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.

Also Liked

LostKobrakai

LostKobrakai

I’d explicitly handle all the error pages you expect to have custom branding on. Leave ErrorHandler to the truely exceptional case.

Last Post!

rhcarvalho

rhcarvalho

Thanks for the replies!

Where Next?

Popular in Questions Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New

We're in Beta

About us Mission Statement