# Custom Errors not rendering

**URL:** <https://talk.observablehq.com/t/custom-errors-not-rendering/4968>\
**Category:** Help\
**Created:** [April 23, 2021, 12:07pm UTC](https://talk.observablehq.com/t/custom-errors-not-rendering/4968 "2021-04-23T12:07:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomlarkworthy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tomlarkworthy/32/5940_2.png) [@tomlarkworthy](https://talk.observablehq.com/u/tomlarkworthy)\
**Post date:** [April 23, 2021, 12:07pm UTC](https://talk.observablehq.com/t/custom-errors-not-rendering/4968/1 "2021-04-23T12:07:34Z")

</div>

I have reported this bug [Certain Custom Error messages don't get displayed properly · Issue #87 · observablehq/feedback · GitHub](https://github.com/observablehq/feedback/issues/87)

Here is a notebook that demonstrates the FirebaseError do not render properly.

> **[Observable](https://observablehq.com/@tomlarkworthy/custom-error-weirdness)**
>
> Explore and visualize data. Share and publish your insights. Discover and be inspired.

Its something to do with message being an accessor and maybe typescript is implicated but I feel like it’s a bug in the Error detection routine. I have seen this problem in Google API clients too, so I feel like its a path other libraries might suffer from.

Here is FirebaseError implementation: [firebase-js-sdk/errors.ts at 5ad7ff2ae955c297556223e6cb3ad9d4b897f664 · firebase/firebase-js-sdk · GitHub](https://github.com/firebase/firebase-js-sdk/blob/5ad7ff2ae955c297556223e6cb3ad9d4b897f664/packages/util/src/errors.ts#L74). Its not particularly outlandish other than being written in Typescript

---

<div class="post-metadata">

**Author:** ![edeboursetty](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/edeboursetty/32/4875_2.png) [@edeboursetty](https://talk.observablehq.com/u/edeboursetty)\
**Post date:** [April 23, 2021, 1:10pm UTC](https://talk.observablehq.com/t/custom-errors-not-rendering/4968/2 "2021-04-23T13:10:32Z")

</div>

Hello,

This is not really Firebase-related. You’d get the same from `throw {a:1}`.  
This is because the error object that’s thrown from Firebase does not implement a toString method. Since the object thrown could be whatever, Observable can’t really know what to do with it.  
It’d be better if Firebase derived its error object from the standard Error type…

Edit: sorry, I hadn’t seen the Firebase code.

Probably related to this: [https://stackoverflow.com/a/41102182](https://stackoverflow.com/a/41102182)

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [April 23, 2021, 1:29pm UTC](https://talk.observablehq.com/t/custom-errors-not-rendering/4968/3 "2021-04-23T13:29:57Z")

</div>

+1 to what @edeboursetty said. Extending Error would give the correct toString behavior and a stack trace.

---

<div class="post-metadata">

**Author:** ![tomlarkworthy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tomlarkworthy/32/5940_2.png) [@tomlarkworthy](https://talk.observablehq.com/u/tomlarkworthy)\
**Post date:** [April 23, 2021, 2:01pm UTC](https://talk.observablehq.com/t/custom-errors-not-rendering/4968/4 "2021-04-23T14:01:31Z")

</div>

Thanks for the link. Yeah seems to be TS compiler targeting ES5

’ the problem is that the TypeScript compiler is transpiling to ES5, and `Error` cannot be correctly subclassed using only ES5 features;’

not sure to fix this… I guess recompile the SDK with a different target is the right move (?)

I guess Google API clients similarly are targeting ES5 too.

---

<div class="post-metadata">

**Author:** ![tomlarkworthy](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tomlarkworthy/32/5940_2.png) [@tomlarkworthy](https://talk.observablehq.com/u/tomlarkworthy)\
**Post date:** [April 23, 2021, 4:12pm UTC](https://talk.observablehq.com/t/custom-errors-not-rendering/4968/5 "2021-04-23T16:12:14Z")

</div>

well I bumped the dependancy version and the errors work now (see notebook)  
I changed SDK version from 7.21.0 to 8.4.1  
I looked at the git (tags/firebase@7.21.0) to see what was different and I could not see any changes so the mystery remains as to the root cause but my immediate problems are solved.

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [April 23, 2021, 4:19pm UTC](https://talk.observablehq.com/t/custom-errors-not-rendering/4968/6 "2021-04-23T16:19:53Z")

</div>

> [@tomlarkworthy](#):
>
> so the mystery remains as to the root cause

You were looking at the wrong file. FirebaseStorageError is defined [here](https://github.com/firebase/firebase-js-sdk/blob/firebase%407.21.0/packages/storage/src/implementation/error.ts) and was changed to extend from FirebaseError [in October '20](https://github.com/firebase/firebase-js-sdk/commit/2b06694da69915352c24cb26f570a129fc04868b).

Take a closer look at the screenshot that I shared in [Certain Custom Error messages don't get displayed properly · Issue #87 · observablehq/feedback · GitHub](https://github.com/observablehq/feedback/issues/87#issuecomment-825641314)
