throw Questions

4

Solved

I am currently developing REST services and throwing BadRequestException for all of the following, 1. Path parameter is invalid 2. Query parameter is invalid 4. Input request object has missing at...
Equitation asked 8/3, 2016 at 13:46

3

Solved

It might be obvious, but I still fail to understand the difference between throw and rethrow and when do either of those should be used?
Megdal asked 15/8, 2020 at 3:5

14

Solved

I want to write a common error handler which will catch custom errors thrown on purpose at any instance of the code. When I did throw new Error('sample') like in the following code try { throw n...
Claim asked 6/2, 2012 at 6:7

8

How can throw an error with options or a status code and then catch them? From the syntax here, it seems we can through the error with additional info: new Error(message, options) So, can we throw...
Pagel asked 13/9, 2021 at 16:6

3

Solved

The biggest misunderstanding for me in Swift is the throws keyword. Consider the following piece of code: func myUsefulFunction() throws We cannot really understand what kind of error it will th...
Whortleberry asked 21/11, 2016 at 11:0

4

Solved

I am new at Java and am experiencing a bit of a problem with throwing exceptions. Namely, why is this incorrect public static void divide(double x, double y) { if (y == 0){ throw new Exception(&q...
Alignment asked 23/11, 2013 at 0:32

5

PEP 342 (Coroutines via Enhanced Generators) added a throw() method to generator objects, which allows the caller to raise an exception inside the generator (as if it was thrown by the yield expres...
Spiro asked 14/7, 2012 at 16:50

9

Here is what I want to do: var setting = process.env.SETTING || throw new Error("please set the SETTING environmental variable"); ^^^^^ But the interpreter complains about "Syntax Error: Unexpe...
Montgomery asked 3/3, 2012 at 9:32

8

Solved

When is it appropriate to use a ThrowHelper method instead of throwing directly? void MyMethod() { ... //throw new ArgumentNullException("paramName"); ThrowArgumentNullException("paramName"); ...
Lucielucien asked 30/12, 2009 at 12:48

3

Solved

I'm learning to use python. I just came across this article: http://nedbatchelder.com/blog/200711/rethrowing_exceptions_in_python.html It describes rethrowing exceptions in python, like this: try: ...
Bode asked 28/7, 2014 at 18:36

11

Solved

I'm having a debate with a co-worker about throwing exceptions from constructors, and thought I would like some feedback. Is it OK to throw exceptions from constructors, from a design point of vie...
Trephine asked 1/5, 2009 at 9:56

3

Solved

I'm writing a test for a function, and have to trigger the .catch part of that function, but Jasmine's spiesfor some reason can't do that. Method to be tested: foo(){ doStuff() .catch((error) =&gt...
Bachelor asked 8/3, 2018 at 12:1

0

Depending on the nodejs framework, there are usually two ways to manage errors. Throw them (ie throw new Error('invalid id');) Return them (ie return { 400: 'invalid id' };) Due to old advice tha...
Westbound asked 12/1, 2022 at 6:13

7

Why can't I just throw an Error inside the catch callback and let the process handle the error as if it were in any other scope? If I don't do console.log(err) nothing gets printed out and I know n...
Ubangi asked 8/6, 2015 at 17:20

2

Solved

It is well known that throw can be placed as the second or the third operand of C++ ternary operator ?:. But can it be inside a comma subexpression of there operands? It looks like compilers diverg...
Mezzorilievo asked 14/8, 2021 at 8:47

7

Solved

I am facing the famous 'Incorrect syntax' while using a THROW statement in a T-SQL stored procedure. I have Googled it and checked the questions on StackOverflow but the solutions proposed (and str...
Subminiature asked 15/10, 2014 at 7:41

6

Solved

I have always seen Throwable/Exception in the context of errors. But I can think of situations where it would be really nice to extend a Throwable just to break out of a stack of recursive method c...
Albers asked 1/8, 2011 at 3:22

1

Solved

I'm super new at coding with Flutter and following this course that let's me create stateful widget. The problem is when I do, I get this throw UnimplementedError(); It should return to null....
Henhouse asked 30/12, 2020 at 13:35

1

Solved

I have a button in some view that calls a function in the ViewModel that can throw errors. Button(action: { do { try self.taskViewModel.createInstance(name: self.name) } catch DatabaseError.CanN...
Harbaugh asked 27/8, 2020 at 17:36

5

Solved

I've been learning Angular 4 and everything was going smoothly until I tried to implement catch handling in a service. I'm trying to use "rxjs" catch and throw but I've got an undefined function er...
Lyly asked 2/8, 2017 at 15:20

3

Solved

I'm using a lot of async network request (btw any network request in iOS need to by async) and I'm finding way to better handle errors from Apple's dataTaskWithRequest which not supports throws. I...
Straticulate asked 22/1, 2016 at 23:43

1

I was trying to find a way in Flutter/Dart to mark a function that may throw an exception during its execution. After some time searching in the documentation and Google I did not find any way of d...
Jaal asked 13/2, 2020 at 12:36

8

I have been coding in Java for a while now. But sometimes, I don't understand when I should throw the exception and when should I catch the exception. I am working on a project in which there are l...
Illimani asked 8/9, 2013 at 0:2

2

Solved

I'm looking through questions for Microsoft's 70-761 exam and I came across a troublesome one. The question asks to 'produce a warning if '. It seems obvious that I should use RAISERROR (or THROW)...
Kweichow asked 31/3, 2018 at 20:25

5

Solved

I want a central place to extract information from an exception, set all the information I need to its message parameter and then rethrow that information as an Exception of the same type. The bet...
Numismatology asked 26/7, 2012 at 14:20

© 2022 - 2024 — McMap. All rights reserved.