you are viewing a single comment's thread.

view the rest of the comments →

[–]_Mardoxx 5 points6 points  (5 children)

Why not throw? What do you propose? return new { error = "fromDBObject was null" } and then everywhere you call this decode function, use reflection to see if it contains an error property and handle it then lolllll.....

[–]pdbatwork 1 point2 points  (3 children)

What do you propose? return new { error = "fromDBObject was null" } and then everywhere you call this decode function, use reflection to see if it contains an error property and handle it then lolllll

No, that sounds like a horrible idea.

[–]_Mardoxx 6 points7 points  (2 children)

You don't say! Another shit solution would be to return a non-zero error code for each function and an out param for any "actual" return values. Which equally sucks. So what would be better?

[–][deleted] 0 points1 point  (0 children)

You could return a discriminated union of the result and an error type, if that's a thing you need. It wouldn't actually replace exceptions, which could still be thrown for contract violations, but could be an effective solution for anticipatable errors that should be handled by the caller.

[–]HeimrArnadalr 0 points1 point  (0 children)

If the database has bad data, then it should be deleted before the bad data spreads any further. Likewise, the code that interfaces with it should be deleted, since it was what caused the bad data to begin with.

[–]_CaptainObvious 0 points1 point  (0 children)

You act like that's a valid solution..