Oren Eini

aka Ayende Rahien

Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,575
|
Comments: 51,189

Copyright ©️ Ayende Rahien 2004 — 2025

Privacy Policy · Terms
filter by tags archive
stack view grid view
  • architecture (606) rss
  • bugs (450) rss
  • challanges (123) rss
  • community (377) rss
  • databases (481) rss
  • design (893) rss
  • development (640) rss
  • hibernating-practices (71) rss
  • miscellaneous (592) rss
  • performance (397) rss
  • programming (1085) rss
  • raven (1442) rss
  • ravendb.net (526) rss
  • reviews (184) rss
  • 2025
    • May (7)
    • April (10)
    • March (10)
    • February (7)
    • January (12)
  • 2024
    • December (3)
    • November (2)
    • October (1)
    • September (3)
    • August (5)
    • July (10)
    • June (4)
    • May (6)
    • April (2)
    • March (8)
    • February (2)
    • January (14)
  • 2023
    • December (4)
    • October (4)
    • September (6)
    • August (12)
    • July (5)
    • June (15)
    • May (3)
    • April (11)
    • March (5)
    • February (5)
    • January (8)
  • 2022
    • December (5)
    • November (7)
    • October (7)
    • September (9)
    • August (10)
    • July (15)
    • June (12)
    • May (9)
    • April (14)
    • March (15)
    • February (13)
    • January (16)
  • 2021
    • December (23)
    • November (20)
    • October (16)
    • September (6)
    • August (16)
    • July (11)
    • June (16)
    • May (4)
    • April (10)
    • March (11)
    • February (15)
    • January (14)
  • 2020
    • December (10)
    • November (13)
    • October (15)
    • September (6)
    • August (9)
    • July (9)
    • June (17)
    • May (15)
    • April (14)
    • March (21)
    • February (16)
    • January (13)
  • 2019
    • December (17)
    • November (14)
    • October (16)
    • September (10)
    • August (8)
    • July (16)
    • June (11)
    • May (13)
    • April (18)
    • March (12)
    • February (19)
    • January (23)
  • 2018
    • December (15)
    • November (14)
    • October (19)
    • September (18)
    • August (23)
    • July (20)
    • June (20)
    • May (23)
    • April (15)
    • March (23)
    • February (19)
    • January (23)
  • 2017
    • December (21)
    • November (24)
    • October (22)
    • September (21)
    • August (23)
    • July (21)
    • June (24)
    • May (21)
    • April (21)
    • March (23)
    • February (20)
    • January (23)
  • 2016
    • December (17)
    • November (18)
    • October (22)
    • September (18)
    • August (23)
    • July (22)
    • June (17)
    • May (24)
    • April (16)
    • March (16)
    • February (21)
    • January (21)
  • 2015
    • December (5)
    • November (10)
    • October (9)
    • September (17)
    • August (20)
    • July (17)
    • June (4)
    • May (12)
    • April (9)
    • March (8)
    • February (25)
    • January (17)
  • 2014
    • December (22)
    • November (19)
    • October (21)
    • September (37)
    • August (24)
    • July (23)
    • June (13)
    • May (19)
    • April (24)
    • March (23)
    • February (21)
    • January (24)
  • 2013
    • December (23)
    • November (29)
    • October (27)
    • September (26)
    • August (24)
    • July (24)
    • June (23)
    • May (25)
    • April (26)
    • March (24)
    • February (24)
    • January (21)
  • 2012
    • December (19)
    • November (22)
    • October (27)
    • September (24)
    • August (30)
    • July (23)
    • June (25)
    • May (23)
    • April (25)
    • March (25)
    • February (28)
    • January (24)
  • 2011
    • December (17)
    • November (14)
    • October (24)
    • September (28)
    • August (27)
    • July (30)
    • June (19)
    • May (16)
    • April (30)
    • March (23)
    • February (11)
    • January (26)
  • 2010
    • December (29)
    • November (28)
    • October (35)
    • September (33)
    • August (44)
    • July (17)
    • June (20)
    • May (53)
    • April (29)
    • March (35)
    • February (33)
    • January (36)
  • 2009
    • December (37)
    • November (35)
    • October (53)
    • September (60)
    • August (66)
    • July (29)
    • June (24)
    • May (52)
    • April (63)
    • March (35)
    • February (53)
    • January (50)
  • 2008
    • December (58)
    • November (65)
    • October (46)
    • September (48)
    • August (96)
    • July (87)
    • June (45)
    • May (51)
    • April (52)
    • March (70)
    • February (43)
    • January (49)
  • 2007
    • December (100)
    • November (52)
    • October (109)
    • September (68)
    • August (80)
    • July (56)
    • June (150)
    • May (115)
    • April (73)
    • March (124)
    • February (102)
    • January (68)
  • 2006
    • December (95)
    • November (53)
    • October (120)
    • September (57)
    • August (88)
    • July (54)
    • June (103)
    • May (89)
    • April (84)
    • March (143)
    • February (78)
    • January (64)
  • 2005
    • December (70)
    • November (97)
    • October (91)
    • September (61)
    • August (74)
    • July (92)
    • June (100)
    • May (53)
    • April (42)
    • March (41)
    • February (84)
    • January (31)
  • 2004
    • December (49)
    • November (26)
    • October (26)
    • September (6)
    • April (10)
Deep Dive into RavenDB webinars
  previous post next post  
May 25 2010

And now this is what I call error handling

time to read 1 min | 19 words

image

Tweet Share Share 31 comments
Tags:
  • Raven

  previous post next post  

Comments

Ben Taylor
25 May 2010
09:20 AM
Ben Taylor

That's what I call Just In Time Documentation. Or Context Sensitive Help.

grega_g
25 May 2010
09:21 AM
grega_g

DRY violation?

Huseyin Tufekcilerli
25 May 2010
09:24 AM
Huseyin Tufekcilerli

This guy seriously needs to learn about StringResources

Andrew
25 May 2010
09:41 AM
Andrew

Shouldn't it be numberOfRequests++ (a max of 1 query should mean 1 query is OK, but 2 is not) :P

armoured.frog
25 May 2010
09:56 AM
armoured.frog

don't mean to nitpick..but did you mean "result in a more responsive application."

Rob Ashton
25 May 2010
10:14 AM
Rob Ashton

I quite like the concept of a more responsible application.

Dennis
25 May 2010
10:36 AM
Dennis

It should throw a MaximumNumberOfRequestsException instead. You aren't doing an Invalid operation, you have just passed the useful limit.

And why is it I would always have to know ahead of time how many queries I am going to be executing. This will be an absolute nightmare for an application 10 years down the road where the source code is long gone.

Neil Barnwell
25 May 2010
10:45 AM
Neil Barnwell

I like the idea of error messages that actually say what the problem is, and even tell you what to do, but I'm torn. I'm torn because the message is effectively a kind of magic string that has details like configuration item names etc, which is going to go out of date if you refactor in the future (say for example you decide to write a clever algorithm that automatically works out the max requests value based on historical usage to determine extraordinary behaviour).

Aikin
25 May 2010
11:13 AM
Aikin

Hei guys! That is the ESSENTIAL! The idea. No more.

Try to do the same proper way (resources, exception helpers, ...).

And when you finish just compare your (COOL and PROPER) code with the one provided. Is it EASY to understand what you did want to explain?

Ayende Rahien
25 May 2010
11:22 AM
Ayende Rahien

armoured.frog,

Yes, thanks, fixed.

Ayende Rahien
25 May 2010
11:23 AM
Ayende Rahien

Neil,

I learned that style from Castle, where it has been successful for over half a decade.

Neil Barnwell
25 May 2010
11:36 AM
Neil Barnwell

Ayende,

Yeah, I have to admit I've always wanted to do it, but always changed my mind at the last minute because of reason I mentioned. It's kind've like documentation - it's hard to keep it up to date and in-sync with the code.

Do you have any tips for keeping these kind of messages relevant over time, when there are many of them? Surely even you can't just remember where they all are and update them when something changes? :)

Rafal
25 May 2010
11:41 AM
Rafal

Nice error message, but in this case I'd rather warn the administrator and continue servicing requests without scarying application users and suggesting the application is broken.

Ayende Rahien
25 May 2010
11:53 AM
Ayende Rahien

Neil,

Those type of things don't change often.

And you basically need to remember those.

Nothing really fancy or high tech. The advantage that you can get from that is huge

Ayende Rahien
25 May 2010
11:53 AM
Ayende Rahien

Rafal,

No one read the logs.

Peter
25 May 2010
11:59 AM
Peter

I like these kind of error messages, because they help a developer much more than general messages (NullReferenceException anyone?).

@Neil: if you use ReSharper to rename methods, it will search in strings also, so that shouldn't be a problem.

Oh, also some nitpicking: ... Raven provideS facilities ...

Nice work, can't wait to try out Raven.

tobi
25 May 2010
12:05 PM
tobi

Just great. I wish it was always like this. Both the message and the "warning" exception that you have to explicitly disable.

Geert Baeyaert
25 May 2010
12:27 PM
Geert Baeyaert

You probably don't want to increment numberOfRequests when you throw the exception.

Matthew Espinet
25 May 2010
13:53 PM
Matthew Espinet

What does it want me to do?

Demis Bellot
25 May 2010
14:42 PM
Demis Bellot

I think long error messages like this would break the rendering of UI error/warnings on the client.

I prefer an error code and a 'succinct error message' and a url for a more detailed explanation where I could explore other comments and solutions from people who have also encountered this error. If you don't provide a url yourself then you should at least supply an error code so its googable.

IMHO motivations behind why you've chosen to throw an error have no place in an Exception message (that's what documentation is for) - it's long enough as it is.

Darren Kopp
25 May 2010
15:38 PM
Darren Kopp

And then that throws an OutOfMemoryException XD

Matt Warren
25 May 2010
16:33 PM
Matt Warren

@Dennis, you can override the default if you want to. but see groups.google.com/.../d0cfb634b89a75e8 for a discussion of why you might not want to.

Dan Finch
25 May 2010
16:36 PM
Dan Finch

This is a good thing

Diego Mijelshon
25 May 2010
16:37 PM
Diego Mijelshon

I like the idea.

One of the things I LOVE about NHibernate, for example, is that the error messages usually give you enough information to know what's wrong and how to fix it without having to open a debugger every time.

The only change I'd do would be introducing a MaximumNumberOfRequestsException like Dennis suggested (whether or not to derive it from InvalidOperationException is up to you)

Kevin Kuebler
25 May 2010
17:25 PM
Kevin Kuebler

throw new YerDoinItWrongException();

;-)

Isaac
25 May 2010
20:35 PM
Isaac

Conceptually great, but the writing could use some help. "It is advisable that you'll look into reducing" should just be "Consider reducing".

Steve Py
25 May 2010
22:33 PM
Steve Py

+1 to Geert !

Incrementing then throwing the exception is a bad idea. If the exception is caught and handled (I.e. make the requester wait, etc.) then you've increased the count without using a request; Poluting your request count with false requests, hindering performance when "real" requests are let go.

Your intent might be that during development developers would receive this exception and re-factor their design. Real-world though is that stuff like this will come up in UAT/Production and bug fixes will effectively be jury-rigs. A caught and handled exception in this case is now a behaviour bug. It's fine to provide details within the exception, if something needs to be told to a user they should be presenting an application-meaningful exception message anyways.

Ayende Rahien
25 May 2010
23:22 PM
Ayende Rahien

Steve,

The problem isn't temporary, if you make another request, it should be blocked as well.

Steve Py
25 May 2010
23:50 PM
Steve Py

Ah, so it's total requests, not current requests. I.C.

Jeff Tucker
26 May 2010
18:03 PM
Jeff Tucker

What about "throw new BadCodingPracticeException" instead?

Troy
27 May 2010
01:04 AM
Troy

This is the result of your years of support.

I don't think you should put training or enforce good practice through error messages. But, neither can I say I wouldn't do it. At the end of the day, losing some number of phone calls to your tech support is money in your pocket--both from less support AND from the bad press: "This stupid Raven thing runs so slow . . ." yada, yada, yada.

I'd search hard for a more appropriate vehicle for the message. But, maybe there isn't one that would be as effective.

Comment preview

Comments have been closed on this topic.

Markdown formatting

ESC to close

Markdown turns plain text formatting into fancy HTML formatting.

Phrase Emphasis

*italic*   **bold**
_italic_   __bold__

Links

Inline:

An [example](http://url.com/ "Title")

Reference-style labels (titles are optional):

An [example][id]. Then, anywhere
else in the doc, define the link:
  [id]: http://example.com/  "Title"

Images

Inline (titles are optional):

![alt text](/path/img.jpg "Title")

Reference-style:

![alt text][id]
[id]: /url/to/img.jpg "Title"

Headers

Setext-style:

Header 1
========
Header 2
--------

atx-style (closing #'s are optional):

# Header 1 #
## Header 2 ##
###### Header 6

Lists

Ordered, without paragraphs:

1.  Foo
2.  Bar

Unordered, with paragraphs:

*   A list item.
    With multiple paragraphs.
*   Bar

You can nest them:

*   Abacus
    * answer
*   Bubbles
    1.  bunk
    2.  bupkis
        * BELITTLER
    3. burper
*   Cunning

Blockquotes

> Email-style angle brackets
> are used for blockquotes.
> > And, they can be nested.
> #### Headers in blockquotes
> 
> * You can quote a list.
> * Etc.

Horizontal Rules

Three or more dashes or asterisks:

---
* * *
- - - - 

Manual Line Breaks

End a line with two or more spaces:

Roses are red,   
Violets are blue.

Fenced Code Blocks

Code blocks delimited by 3 or more backticks or tildas:

```
This is a preformatted
code block
```

Header IDs

Set the id of headings with {#<id>} at end of heading line:

## My Heading {#myheading}

Tables

Fruit    |Color
---------|----------
Apples   |Red
Pears	 |Green
Bananas  |Yellow

Definition Lists

Term 1
: Definition 1
Term 2
: Definition 2

Footnotes

Body text with a footnote [^1]
[^1]: Footnote text here

Abbreviations

MDD <- will have title
*[MDD]: MarkdownDeep

 

FUTURE POSTS

  1. NOT Sharding RavenDB Vector Search - 15 hours from now
  2. Optimizing the cost of clearing a set - 4 days from now
  3. Scaling HNSW in RavenDB: Optimizing for inadequate hardware - 6 days from now

There are posts all the way to May 14, 2025

RECENT SERIES

  1. RavenDB News (2):
    02 May 2025 - May 2025
  2. Recording (15):
    30 Apr 2025 - Practical AI Integration with RavenDB
  3. Production Postmortem (52):
    07 Apr 2025 - The race condition in the interlock
  4. RavenDB (13):
    02 Apr 2025 - .NET Aspire integration
  5. RavenDB 7.1 (6):
    18 Mar 2025 - One IO Ring to rule them all
View all series

RECENT COMMENTS

  • ถูกใจ ร้านนี้สุดๆ! อุปกรณ์ จาก inkspa pantip ทำให้ ผลงาน สวย จ้าง เสื้อ ทีม ได้ งาน ลงตัว ราคา คุ้ม ชวน ใคร อยากได้ ดีไซน...
    By ink-spa พันทิป on The null check that didn't check for nulls
  • But in case you have nullability checks enabled (i.e. `<Nullable>enable</Nullable>`), then you'll have a compiler warning on ...
    By Samyon Ristov on The null check that didn't check for nulls
  • Grok wasn't *wrong*. It only said that `_items` can't be null for the condition to evaluate to `true`, but didn't say anythi...
    By Johannes Egger on The null check that didn't check for nulls
  • When I started enabling NRT, I remember I was initially confused when all variables (for reference types) declared with `var`...
    By riccardo on The null check that didn't check for nulls
  • That is surprising - I think of var as a shorthand that does not affect the final result of the compilation. I wouldn't expec...
    By Chris B on The null check that didn't check for nulls

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats
}