|
Yes. But not frequently.
I don't know what you mean by "how they look".
|
|
|
|
|
Mostly, I limit myself to creating custom exceptions for class libraries. Some of the circumstances in which I find them useful...
1) Allow the consumer to easily differentiate and catch my exception.
2) Share additional information with the consumer, usually via properties, without forcing them to de-serialize the message text.
3) The occasional instance when the built-in exceptions don't fit.
Not sure what you mean by "how they look".
|
|
|
|
|
Generally I only do it to differentiate problems my code detects from those the framework does. So if a file doesn't exist, that's not something I have control over - but if there is a problem with data I'm processing directly, the that's a custom exception candidate so it can be trapped as an exception class rather than as part of a generic framework exception group.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
RandyBuchholz wrote: Do you use custom exceptions? Yes, for situations specific to the business domain of my APIs. I use standard exceptions like ArgumentNullException where necessary, and business specific exceptions like ObjectNotFoundException and NoPrivilegeException in other cases.
RandyBuchholz wrote: do you keep them basic Yes, almost always.
/ravi
|
|
|
|
|
RandyBuchholz wrote: By how they look, I mean do you keep them basic and mostly use message , or do you do things like populate data ?
What OG said. I never populate the exception with data - if useful data is associated with an exception, it gets written out to an error file / table / email / other logging mechanism, by the handler of the exception, never the invoker.
|
|
|
|
|
For me, the occasional exception to this rule is a class library for common consumption. As an example, I've had a case where I had an (uncommon) field-level aware consumer. Sharing the name of the offending field, had benefit to the consumer, but no (obvious) benefit to the provider / consumed resource.
Other than this edge case, I agree completely with your assertion.
|
|
|
|
|
I'm of the opinion that a library should add as few dependencies as possible.
So I'd rather populate the Data property of the exception and send it upwards to a higher level and have it logged there.
|
|
|
|
|
Few years back (back in the days of fulltime) I've saw cases where underling juniors too smart for their own good used 'custom exceptions' to achieve [and attempt to hide] GOTO-out-of-a-loop.
When confronted, 'where I have goto? you see I doing very properly one.'
(It's one of the reasons I avoid public domain source code repositories where anyone can contribute, too many juniors showing off their skills in little known facets of the language often end up producing crap, the above being a regular common example of such.)
This internet thing is amazing! Letting people use it: worst idea ever!
|
|
|
|
|
Add Custom Data to Exceptions -- Visual Studio Magazine[^]
I prefer to fill the data over adding extra logging-statements.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I do create custom exceptions with data, and use them to log whenever they triggered...
"The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge". Stephen Hawking, 1942- 2018
|
|
|
|
|
OK just took a call from yet another scammer trying to sell me bogus health insurance. For reasons I cannot explain, I decided to pretend to be French (this only works if the caller doesn't know French). He finally grew frustrated and asked me to be patient and said he was trying to find someone who knew "my" language (I dunno French either - I was just gleefully babbling away). At this point I asked him how it felt to have someone waste his time with a bunch of phony BS the way he was wasting mine. His response, while not fit to post here, was epic. I am definitely gonna do this again.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
It is sometimes such a wonderful game which I'm doing also when I am in a good mood
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
I usually just hang up and then block the number. But today I'm bored.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
It got to the point that I put "SCAM LINE1", "SCAM LINE2", and so on into the phone so I knew who was ringing me. If I had the time, I'd wind 'em up - but if not it was easy to get rid of them: "Do you tell your mother you're a scammer?" when you answer normally gets a burst of swearing and a disconnect.
On of my favorite time-taking ways to wind 'em up is to do exactly what they say. But on an Android tablet, instead of a PC.
Pity - they don't seem to want to talk to me anymore, and I'm sure that my "Windows Router" is raising problems with Microsoft again.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
OriginalGriff wrote: "Do you tell your mother you're a scammer?"
Hadn't thought of that one. Gotta give it a try.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
Got a call yesterday about the soon-to-expire extended warranty on my 2014 Jeep Cherokee. Weird, since I do in fact own a Cherokee but it's way older. I'm guessing that since Cherokees are so popular they're playing the odds. I just hung up. Probably could have had some fun with that one, too.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
"Please hold"...horrible holding music (for one minute)..."Sorry, just one more minute"...repeat
|
|
|
|
|
If I have time, I keep them on the line as long as possible, acting like I'm interested. I play really dumb and ask them to go over the same things many times. I try to get them to the point where they are asking for payment info and then tell them I don't have a credit card or email.
|
|
|
|
|
RandyBuchholz wrote: o go over the same things many times I get enough of that in meetings in the office, I'm not sure I could do it to someone else... oh wait it is a scammer we are talking about.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Always love to hear a success story.
I will have to try this on head hunters that started calling me on a daily basis a couple of week's ago. I'm 69 and have no intention of going back to work.
Everyone has a photographic memory; some just don't have film. Steven Wright
|
|
|
|
|
We're having provincial elections here next week in Ontario, and reps from all parties have been calling rather frequently to make their pitch.
During the last call I received, I immediately interrupted the (I'm sure otherwise very nice) lady to point out that they'd been calling every single day for the past week (which is absolutely true), and that by now they had already got their point across...and requested they permanently take my name/number (which they obviously have, since they asked for me by name) off their phone list - else the party they represent was automatically losing my vote.
The scam here is that even though there's a do-not-call registry here in Canada, political parties are exempt[*] from it. It sure is nice when you get to make the rules.
[*] And newspapers trying to sell subscriptions. Why? Because the papers in Canada are owned by people with affiliations to a certain political party. Which? Here's a hint: The one that was running the country when the law was made.
|
|
|
|
|
dandy72 wrote: even though there's a do-not-call registry here in Canada
Same here. Pretty much anyone with an affiliation to government is exempt from our Do-Not-Call- Registry. And of course the scammers don't care. Most of them are outside the country.
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|
I once played along with a scammer that said I had won some money in Vegas that I had left unclaimed. The kind of money that you had to pay taxes on first before it would be sent to you. It went on for several phone calls over several days until I finally got him to admit that he was a scammer. We actually had an interesting conversation after that -- like apparently a lot people fall for his scam. He even asked me how I thought he could improve his scam to make it more believable. But then he had the audacity to ask if I could give him a list of names and numbers he could try his scam on. Well, I told him that I could send him a list of 100 people, all he had to do was first send me a valid $100 Walmart gift card.
-NP
Never underestimate the creativity of the end-user
|
|
|
|
|
Sometimes the true reward for completing a task is not the money, but instead the satisfaction of a job well done. But it's usually the money.
|
|
|
|
|