Questions tagged [exceptionhandler]

186 questions
0
votes
3 answers

Avoiding exception hiding when finally block could throw

When you have a process which you’ve wrapped in a try catch, finally, and the action in the final could possibly throw, how do you handle exception, hiding? Here's an example of a problem and a possible fix. Does the fix look ok, or am I…
Peter Kahn
  • 12,364
  • 20
  • 77
  • 135
0
votes
1 answer

Expectation handling in python

Below are two function definition def function1(): try: #Code #Code #code to read file is here #code return smth except Exception as e: raise Exception ('smth1smth1') from e def function2(): …
una
  • 57
  • 3
0
votes
0 answers

Nest can't resolve dependencies of the UsersLineService (UsersLineRepository, HttpService, ?)

Error [Nest] 20898 - 07/23/2023, 6:09:36 PM ERROR [ExceptionHandler] Nest can't resolve dependencies of the UsersLineService (UsersLineRepository, HttpService, ?). Please make sure that the argument dependency at index [2] is available in the…
0
votes
0 answers

Unhandled Exception Event in Blazor

Is there an event to catch all unhandled exceptions in Blazor Server? AppDomain.CurrentDomain.UnhandledException isn't working because all exceptions are technically "handled" by SignalR closing the circuit. Is there an alternative event or other…
0
votes
0 answers

Short messages for MethodArgumentNotValidException

Got a simple DTO for users of my app where I use jakarta validators for the length of the password. public class UserDto { @NonNull @NotBlank private String username; @JsonProperty(access = WRITE_ONLY) @NonNull @ToString.Exclude …
Jason
  • 2,495
  • 4
  • 26
  • 37
0
votes
0 answers

in spring boot app a rest api returns a response fields different from my response dto when an exception like 500 occurs

Getting this response but timestamp and path fields are not in my response dto or exceptionHandler. the endpoint in the instances works correctly and returns the second response when deployed initially but some time later the first response starts…
0
votes
2 answers

Can't get response body from Spring Boot REST API on Error

I spent way too much time on this I thought I would share what I found out. I'm surprised I couldn't find this information anywhere as it would seem like something ever app must have. I expect to be able to send additional data back to the client…
tdemay
  • 649
  • 8
  • 23
0
votes
1 answer

Handle Errors on Asp.net core6 mvc

I am studying asp.net core and I need to fix error handling problems. I have some questions about them 1- should we catch all error types and return specific views each of them? 400 401 403 404 500 and more 2-if yes, which method is the best…
0
votes
1 answer

Why Exception is caught within Spring Boot Controller by @ExceptionHandler but not by @ExceptionHandler in @ControllerAdvice?

In a Spring Boot MVC application I have a controller which calls a service method: @Controller @RequestMapping("/registration") public class RegistrationController { @GetMapping({"/email-confirmation"}) public String…
Slevin
  • 617
  • 1
  • 7
  • 17
0
votes
1 answer

[SpringBoot]: Decorating exception when deserializing @RequestBody

I've got a DTO that represents bank accounts: @Data @AllArgsConstructor public class AccountDto { @NonNull private String id; @NonNull private Long balance; @NonNull private Currency currency; } Currency is an enum where…
Jason
  • 2,495
  • 4
  • 26
  • 37
0
votes
0 answers

Accumulate exceptions to add them in the same REST response

I'm trying to intercept all exceptions that can happen in a REST API request, create a custom message to each one and to add them both to the response. The request below has two errors, one in the field tipo and other in the field formato. The…
0
votes
0 answers

Spring Access Parameter Annotation Value in Rest Controller Advice

Is it possible to access parameter annotation value in restcontroller advice.In my case MyApiRequest is not valid for that reason I got 400 error.In restcontrolleradvice I catch this error and Also want some logging with myparameter value.But I cant…
Bilgehan
  • 1,135
  • 1
  • 14
  • 41
0
votes
1 answer

I can't write my own @ExceptionHandler for HttpMediaTypeNotAcceptableException in Spring Boot

I want to return my own error message in rest controller when accept header is "application/xml". The thing is if this header is set then spring throws HttpMediaTypeNotAcceptableException. I wanted to use @ExceptionHandler and I added a new method…
Mixss
  • 45
  • 4
0
votes
0 answers

Global exception handler that just log and go on with the exception

I need to create a global exception handler just to log what data sent caused the exception with some other little things and, after this, go on with the normal exception handling on my application. I tried a lot of things, but im putting the last…
0
votes
1 answer

Is there any way to get db-warnings from the database in C# OdbcConnection?

I'm using the Odbc library with .NET Core 7 and, sometimes when gross errors occur in my sql commands ("like: select * from Non-Existent-object"), an Exception is thrown, then i can handle and identify the error more easily. Still, recently i…