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

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
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
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
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
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54092 488
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54996 245
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44608 311
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement