throw Questions
2
Solved
This is my first time using exception handling so be gentle. I have a simple blob class that accepts an ID, the id must be between 30 and 50 or else an exception is thrown.
public class Blob {
in...
Jacaranda asked 16/9, 2013 at 22:53
6
Solved
At the moment I'm extending my JavaScript project with error handling. The throw statement is playing an important role here:
throw new Error("text"); // Error: text
However, can I also throw a ...
Holds asked 4/3, 2011 at 0:9
6
Consider:
try {
// Some code here
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw e;
}
What is the difference between throw e and throw new Exception(e)?
try {
// Some code...
2
Solved
I have one app with multiple targets (each target is for another client as separate application with different name, bundle identifier etc).
I have method:
fileprivate static func loadSessionFrom...
1
Solved
I am working on a project that uses a legacy library which uses function definitions like
void func() throw(some_exception);
Since dynamic exception specifications are removed in C++17 I ...
1
Solved
Please find the code in the image below.
1. Assign the returned value of a function, which throws an error actually, to the variable 'withLet' that declared by using keyword 'let'.
2. call 'withLet...
Flamboyant asked 17/1, 2019 at 8:21
8
Solved
Here is the code:
public Response getABC(Request request) throws Exception {
Response res = new Response();
try {
if (request.someProperty == 1) {
// business logic
} else {
throw new Except...
Textualism asked 27/12, 2018 at 7:8
2
In Java (using Java 8 currently), I can write this and all will compile nice and well:
Supplier<Long> asd = () -> {
throw new RuntimeException();
};
Yet, I cannot write this:
Su...
Hindorff asked 30/11, 2018 at 12:40
2
Solved
Below throw code giving lint error Expected an object to be thrown no-throw-literal
throw { code : 403, message : myMessage };
if i try throw new Error, i am not getting eslint but it gives [Obj...
Bangweulu asked 31/10, 2018 at 10:12
1
Solved
I have a forEach loop that check if there are conditions before pushing data in the array:
allow(id, perm, arr) {
const data = { "userId": id, "permissionId": perm };
arr.forEach(key => {
i...
Subjugate asked 30/7, 2018 at 11:47
2
Solved
I am not sure if it is a bug or it is really how things should work?
class A {
init() throws { }
}
class B {
lazy var instance = A()
}
this code compiles without mistakes using XCode 9 and la...
Audet asked 4/6, 2018 at 7:48
4
Solved
Because Swift does not have abstract methods, I am creating a method whose default implementation unconditionally raises an error. This forces any subclass to override the abstract method. My code ...
Saum asked 7/1, 2015 at 21:40
8
Solved
1
Some functions in AudioToolBox always throw __cxa_throw, at the same time the function such as ExtAudioFileDispose works well, the return value zero which is normal.
When I want to use try {} catc...
Bermuda asked 15/1, 2014 at 5:32
3
Solved
I'm playing around with exceptions in PHP. For example, I have a script that reads a $_GET request and loads a file; If the file doesn't exists, an new exception should be thrown:
if ( file_exists...
19
Solved
When there is a post-condition, that return value of a method must not be null, what can be done?
I could do
assert returnValue != null : "Not acceptable null value";
but assertions coul...
Eugene asked 23/7, 2010 at 21:46
1
Solved
I've seen 3 different ways of throwing an error in JavaScript:
throw 'message';
throw Error('message');
throw new Error('message');
What is the difference between them?
Note: I am aware of simi...
Vector asked 19/9, 2017 at 8:18
2
Solved
Throw Expressions work in this case:
string myStr;
public MyObj( string myStr ) =>
this.myStr = myStr ?? throw new ArgumentNullException( "myStr" );
But why doesn't this compile too?
bool ...
2
Solved
I am beginner in c++, and hence apologies for this silly question. I am posting it here because I cannot find a similar answer on stackoverflow.
I was progressing through exceptions in C++ and as ...
3
Solved
Is there any difference between throw() and noexcept other than being checked at runtime and compile time respectively?
This Wikipedia C++11 article suggests that the C++03 throw specifiers are dep...
Shanda asked 11/10, 2012 at 6:9
1
Solved
I'm writing a set of custom exceptions that extend std::exception. In some code, when an exception is caught, I just re-throw it up the chain until the driver main function call catches and prints ...
3
Solved
Objective
Throw InvalidArgumentException in a JavaScript method like one does in Java or similar languages.
Background
I have been trying to familiarize myself with JavaSctipt error handling, an...
Fractional asked 1/7, 2016 at 12:53
5
Solved
Under exceptional circumstances, I want my program to stop processing, output an error to std::cerr, clean up, and exit.
However, calling exit() will not call all the destructors of any objects th...
Selinski asked 28/4, 2017 at 8:35
1
Solved
As far as I understand, rethrows essentially creates two functions from a single declaration/definition, like so:
func f(_ c: () throws -> Void) rethrows { try c()}
// has the same effect as d...
3
Solved
I have an Exception class on which I want to set more information before I throw it. Can I create the Exception object, call some of its functions and then throw it without any copies of it being m...
© 2022 - 2024 — McMap. All rights reserved.