Giter Site home page Giter Site logo

Comments (3)

mssfang avatar mssfang commented on July 24, 2024 1

@leandrodvd I created a TROUBLESHOOT.md guideline to help explain how to handle errors. Hope it helps

https://github.com/Azure/azure-sdk-for-java/pull/40671/files#diff-d1d2dcdfd75f2946c83c56d2d59f3a197d4320f40c8e6630a8722a6ba85b1f86R74

from azure-sdk-for-java.

joshfree avatar joshfree commented on July 24, 2024

@mssfang could you please follow up with @leandrodvd? Is this something that should be covered in the README or TROUBLESHOOT guide

from azure-sdk-for-java.

leandrodvd avatar leandrodvd commented on July 24, 2024

Hi, yeah, the documentation looks like a good start, but it's kinda shallow, only shows what exception to catch, could have more details on the exception content. For instance I learned that the HttpResponseException.getValue() contains an Error object with an error code that tells me what is the actual error. That error code is fundamental to understanding what is the actual error. This kind of detail could be documented.

A better solution (and maybe a separate issue) would be to have the error mapped to some model class that I can use. That's in fact the solution I implemented, I created an "Error" record and on HttpResponseException catch I deserialize the .getValue() content to that class so that I can access the error details (for instance I'm interested in error code so that I can treat content_filter and context_length_exceeded errors so that I can format a nice answer to my user)

I implemented this Error class on my side but I believe this should be part of the SDK

public record HttpResponseExceptionError(
        Error error
) {
}

public record Error(
        String message,
        String type,
        String param,
        String code
) {
}

 try {
            chatCompletions = openAiClient.getChatCompletions(...);
        } catch (HttpResponseException e) {
            HttpResponseExceptionError httpResponseExceptionError = BinaryData.fromObject(e.getValue()).toObject(HttpResponseExceptionError.class);
            log.info("HttpResponseException occurred - error code {}", httpResponseExceptionError.error().code());

from azure-sdk-for-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.