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

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
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
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36689 110
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
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
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
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New

We're in Beta

About us Mission Statement