Code Monkey home page Code Monkey logo

Comments (5)

khellang avatar khellang commented on June 8, 2024

Hello @iaingymware! 👋

Have you looked at the sample in this repo? It shows a bunch of ways you can return custom problem details responses. You can return it directly from controllers, use Map functions when configuring the middle ware etc.

It's hard to give more specific feedback without knowing more details about what you want to achieve.

from middleware.

iaingymware avatar iaingymware commented on June 8, 2024

Hi @khellang

I am using your example here linked just below to capture the FluentValidation Validation Exception.

https://github.com/khellang/Middleware/blob/master/samples/ProblemDetails.Sample/ProblemDetailsOptionsExtensions.cs

This uses the ProblemsDetailFactory to generate a ProblemsDetails instance with errors. This works brilliantly however I want to customise the returned ProblemDetails instance.

Is there a way to use the sample Extension class however provide specific values, i.e Type, Title, Detail etc or do I need to write my own factory implementation similar to yours?

Thanks

from middleware.

khellang avatar khellang commented on June 8, 2024

If I'm not mistaken, the factory methods let you specify every single property of the problem details spec.

from middleware.

iaingymware avatar iaingymware commented on June 8, 2024

So I could use this, but it doesnt accept errors as a param:

image

Then we have this, but it accepts ModelStateDictionary (which i dont have as this is a web api) and no errors details:

image

This which accepts error and status code, but no other params:

image

and then this which is the same but an IDictionary version rather than SerializableError:

image

Sorry if I've missed something or I am mistaken, but I dont see a way to pass all custom ProblemDetails values, as well as the errors dictionary?

Thanks

from middleware.

iaingymware avatar iaingymware commented on June 8, 2024

Hi @khellang

Any update on how I should progress with this?

Thanks

from middleware.

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.