Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API error messages not getting passed #261

Open
ehosch opened this issue Mar 8, 2023 · 10 comments
Open

API error messages not getting passed #261

ehosch opened this issue Mar 8, 2023 · 10 comments

Comments

@ehosch
Copy link

ehosch commented Mar 8, 2023

Tried creating a user with username less than 6 characters, and the error object is null and nothing happens. Tested with the swagger interface and the error message works there.

@kristian014
Copy link

I'm currently experiencing this issue and still trying to figure out the issue

@kristian014
Copy link

kristian014 commented May 1, 2023

@iammukeshm
Issues

  • Create a new Product
  • Enter an existing product name
  • Select Brand and enter a rate
  • Click Submit

Expected Behaviour

  • Fails validation and displays Prospect already exists to the user in the Blazor application

Current Behaviour

  • Something went wrong

Quick helpful debugging
In the APIHelper.cs code below, ex.Result.Errors are null

 catch (ApiException<HttpValidationProblemDetails> ex)
        {
            if (ex.Result.Errors is not null)
            {
                customValidation?.DisplayErrors(ex.Result.Errors);
            }
            else
            {
                snackbar.Add("Something went wrong!", Severity.Error);
            }
        }

@Hamoo17
Copy link

Hamoo17 commented Aug 29, 2023

Facing Same issue . Any update about that issue?

@zrediet
Copy link

zrediet commented Sep 1, 2023

I am facing the same issue. I thought the error was because of my model validation problems but I even tried it with the example Product and Brand ...... The same thing is displayed.

@zrediet
Copy link

zrediet commented Oct 6, 2023

@iammukeshm Issues

* Create a new Product

* Enter an existing product name

* Select Brand and enter a rate

* Click Submit

Expected Behaviour

* Fails validation and displays Prospect already exists to the user in the Blazor application

Current Behaviour

* Something went wrong

Quick helpful debugging In the APIHelper.cs code below, ex.Result.Errors are null

 catch (ApiException<HttpValidationProblemDetails> ex)
        {
            if (ex.Result.Errors is not null)
            {
                customValidation?.DisplayErrors(ex.Result.Errors);
            }
            else
            {
                snackbar.Add("Something went wrong!", Severity.Error);
            }
        }

Not working this way! Any updates? Thanks!

@fcantenot
Copy link

Hello all,

I'm facing the same issue. I tried to search by myself.
When we have a validation error, if for exemple we try to add a product with an existing name, the error is managed by ExceptionMiddleware (FSH.WebApi) et it write the response with an object of type ErrorResult (FSH.WebApi).

ExceptionMiddleware

ExceptionMiddleware2

ErrorResult

The message arrived to blazor client. You can show it with DevTools with an error code 400.
DevToolsError

But it is not displayed. We have "Something went wrong" !

If we take a look inside FSHApi.cs generated with NSwag, we can see that error 400 is not an ErrorResult but a HttpProblemValidationDetails that's why, I guess, like @kristian014 told us, ex.Result.Error is null !

FSHApi Error

I saw a file FSHApiConvention

FSHApiConvention

I don't know, maybe, we have to change it. 400 is not a HttpValidationProblemDetails but an ErrorResult. It is just an idea and a lead I don't know consequences.

What do you think about it @iammukeshm ?

Thanks

@zrediet
Copy link

zrediet commented Oct 11, 2023

Hello all,

I'm facing the same issue. I tried to search by myself. When we have a validation error, if for exemple we try to add a product with an existing name, the error is managed by ExceptionMiddleware (FSH.WebApi) et it write the response with an object of type ErrorResult (FSH.WebApi).

ExceptionMiddleware

ExceptionMiddleware2

ErrorResult

The message arrived to blazor client. You can show it with DevTools with an error code 400. DevToolsError

But it is not displayed. We have "Something went wrong" !

If we take a look inside FSHApi.cs generated with NSwag, we can see that error 400 is not an ErrorResult but a HttpProblemValidationDetails that's why, I guess, like @kristian014 told us, ex.Result.Error is null !

FSHApi Error

I saw a file FSHApiConvention

FSHApiConvention

I don't know, maybe, we have to change it. 400 is not a HttpValidationProblemDetails but an ErrorResult. It is just an idea and a lead I don't know consequences.

What do you think about it @iammukeshm ?

Thanks

I did communicate with @iammukeshm on linkedin regarding the above issue, and he told me that this issue and other issues will be resolved on the next update (.NET 8).

But for those of us who are already working on this version, If the above proposed solution can resolve the issue, I think it is better to try it out.

What do you think?

@fcantenot
Copy link

fcantenot commented Oct 11, 2023

good news thanks ! I can wait the next version (.NET8) ! now I just try the solution to see if everything work correctly !
Did he told you when the next version will be available ?

@zrediet
Copy link

zrediet commented Oct 11, 2023

He said the new version is almost completed! Didn't say when exactly. Did you try the solution to see if it works?

@fcantenot
Copy link

ok thank you ! no,sorry, it was just an idea, I don't master enought the code !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants