Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 499069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:56:52+00:00 2026-05-13T05:56:52+00:00

This title begs for more explanation. Basically, I’m rolling an API that wraps a

  • 0

This title begs for more explanation.

Basically, I’m rolling an API that wraps a web service in a nice heirarchical model. This model exposes things in the form:

var obj = MyRemoteResource.GetForId(1234, SourceEnum.ThatSource);
ApiConsumerMethod(obj.SomeProperty);  //SomeProperty is lazily loaded, and often exposes such lazily loaded properties itself
... etc ...

Where many different RemoteResources* (each with many properties exist). There’s really aggresive cacheing going on, and request throttling to prevent inadvertantly DOS’ing the servers (and getting the IP of the caller banned).

I’ve got all this code working, but I’m not doing much in the way of error handling at the moment. Basically, if the consumer of an API provides an invalid ID, the web server is down, a connection times out, or any other of a plethora of request layer errors occur an exception just percolates up when a property is accessed.

I consider this far less than ideal.

So my question is, how should I wrap these errors up so that it is convenient for a user of this API to manage them?

Some routes I have considered:

  • Just wrap all exceptions in some API defined ones, and document them as thrown.
  • Expose a static ErrorHandler class that allows a user to register notification callbacks for specific errors; falling back to the above behavior when no registration has been made for specific errors.**
  • Null properties on error, and set a LastErrorCode.

Each of these approachs have strengths and weaknesses. I’d appreciate opinons on them, as well as alternatives I haven’t thought of.

If it impacts the discussion at all, the platform class throwing these exceptions is WebClient. Furthermore, usage of WebClient is sufficiently abstract that it could easily be replaced with some other download scheme if needed.

*Which is to say, many different classes

**This would be… wierd. But it maps to the global nature of the failure. This is my least favorite idea thus far.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:56:53+00:00Added an answer on May 13, 2026 at 5:56 am

    I wouldn’t implement fancy error technologies (like events and stuff like this). It’s not easy to judge where and how to use exceptions, but this is no reason to implements other stuff.

    When you request an object by an id which doesn’t exist, what do you have to tell the caller about this? If you just return null, the client knows that it doesn’t exist, there is nothing more to say.

    Exceptions force the caller to care about it. So they should only be used where the caller is expected to do something special. Exception can provide the information why something didn’t work. But if it is an “error” the user could also ignore, an exception is not the best choice.

    There are two common alternatives to exceptions.

    • Use return values which provide information about the result of an action. For instance, logon could return a LogonResult instead of throwing an exception.
    • Write two methods, one throwing an exception, and one (Try…) returning a boolean. The caller decides if it wants to ignore the “error” or not.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 353k
  • Answers 353k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You need to init your window... UIWindow *newwindow = [[UIWindow… May 14, 2026 at 7:45 am
  • Editorial Team
    Editorial Team added an answer It's known bug. Will be fixed Qt 4.6.3. May 14, 2026 at 7:45 am
  • Editorial Team
    Editorial Team added an answer I found this which someone created that calculates distances between… May 14, 2026 at 7:45 am

Related Questions

This is the data currently located in one column: Title Info - Company Here
My config file looks like this: title = myTitle; otherTitle = myOtherTitle; when I
In Jinja2 , I have a base template like this: <title>{% block title %}{%
I have the HTML given below: <ul id=thumbsPhotos> <li src=/images/1alvaston-hall-relaxing-lg.jpg onclick=updatePhoto (this.title)><img src=/images/1alvaston-hall-relaxing-sl.jpg width=56
Using code from this site this.screenshotPreview = function(){ /* CONFIG */ xOffset = 10;

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.