SuperResponse



  • I found an awesome class in this project. If only there were some way to handle “exceptional” cases in C#…

    namespace WTF.Util
    {
        /// <summary>
        /// Generalize return values.
        /// <example>
        /// <pre>
        ///     SuperResponse GetData()
        ///     {
        ///         SuperResponse response = new SuperResponse();
        ///         try
        ///         {
        ///             // Do the operation and get the return value
        ///             response.ReturnValue = foo;
        ///             response.StatusCode = StatusCodes.Success;
        ///             response.Message = "no data";
        ///             return response;
        ///         }
        ///         catch (Exception e)
        ///         {
        ///             response.StatusCode = StatusCodes.Failure;
        ///             response.Message = e.Message;             
        ///             return response;
        ///         }
        ///     }
        /// </pre>
        /// </example>
        /// </summary>
        public class SuperResponse
        {
            public StatusCodes StatusCode { get; set; }
            public string Owner { get; set; }
            public string Message { get; set; }
            public string OptionalMessage { get; set; }
            public object ReturnValue { get; set; }
        }
    }
    

    And yes, of course, it’s used all over the place, along with out parameters for damned near everything.


  • :belt_onion:

    @djork said:

    I found an awesome class in this project. If only there were some way to handle “exceptional” cases in C#…
    Although not perfectly executed here, this is however a useful technique for passing error information across webservices.

    If a webservice throws an exception the client of that service cannot catch it. So the webservice has to catch it himself to avoid failing, serialize the entire exception and send it over to the client who can deserialize it and rethrow a new TechnicalException.

    Looks like .NET 1.1 since not using a generic class, like this

    public class SuperResponse<RETVAL>
    {
    RETVAL ReturnValue {get;set;}
    }

    OTOH, I don't remember having automatic properties in .NET 1.1, so it must be >=2.0. Maybe the author likes casting a lot?

    Edit: BTW, congratulations on your 666th post



  • That's just so awesome. The other day, we were having a discussion about principles behind error handling in our APIs (basically: exceptions, boolean status, error return codes, etc.), but that is so pointless now that I've seen this.

    Plus, it uses a C# feature I've come to love: { get; set; }. Wonderful.



  • @bjolling said:

    OTOH, I don't remember having automatic properties in .NET 1.1, so it must be >=3.0. Maybe the author likes casting a lot?
     

    FTFY



  • @bjolling said:

    Edit: BTW, congratulations on your 666th post



  • @bjolling said:

    Edit: BTW, congratulations on your 666th post

    Only 50 posts late with those congrats., then?

    http://qi.com/talk/viewtopic.php?start=5&t=3049


  • @Cad Delworth said:

    @bjolling said:

    Edit: BTW, congratulations on your 666th post

    Only 50 posts late with those congrats., then?

    http://qi.com/talk/viewtopic.php?start=5&t=3049
    First of all, is that really the best link you could come up with regarding the whole 616 thing?  Second, and more importantly, he congratulated djork on his 666th post, not his Number-of-the-Beast-th post.  Your comment makes no fucking sense.  I hate you.  Have a nice day.


  • @bstorer said:

    @Cad Delworth said:

    @bjolling said:

    Edit: BTW, congratulations on your 666th post

    Only 50 posts late with those congrats., then?

    http://qi.com/talk/viewtopic.php?start=5&t=3049

    First of all, is that really the best link you could come up with regarding the whole 616 thing?  Second, and more importantly, he congratulated djork on his 666th post, not his Number-of-the-Beast-th post.  Your comment makes no fucking sense.  I hate you.  Have a nice day.

    Can I get in on this dogpiling?



  • @morbiuswilters said:

    Can I get in on this dogpiling?
    Well, you know the TDWTF rules of dogpiling.

    1. You do not talk about dogpiling
    2. You do not talk about dogpiling
    3. If someone says "stop," you're not doing it hard enough
    4. Minimum 3 guys to a pile
    5. Only 1 dogpile at a time
    6. No pants
    7. Dogpiles will go on as long as they're fun for morb or pesto or btk
    8. If this is your first time at TDWTF, you have to say something stupid, inviting a dogpile.


  • i never get 2 dogpile

    :(



  • @dhromed said:

    i never get 2 dogpile

    :(

    It's because you always cry and talk about your feelings after we dogpile.  Why can't you just do a few bumps of coke like the rest of us?



  •  I'm sensitive, you arthroprick.


Log in to reply