8,819 questions
Best practices
0
votes
3
replies
99
views
How to prevent individual errors in a for try await loop without stopping the entire sequence?
During a pre-interview call with a company, I got asked a couple questions about swift concurrency. One of the questions was:
When using for try await to iterate through an async sequence, how do you ...
1
vote
2
answers
129
views
Best Practices for try-catch blocks inside the Get part of an indexer [closed]
I've been creating a basic version of a LinkedList class mainly for the sake of an assignment (though also to gain a better understanding of it all). I've gotten to the stage where I'm writing error ...
Best practices
1
vote
4
replies
71
views
Is it bad practise to wrap the code in __main__ in a try-except block?
At my new job they use a try-except construction in the entry-point of the main python script.
if __name__ == "__main__":
try:
main()
except Exception:
...
2
votes
1
answer
118
views
R.utils::withTimeout function not working with stan_glm
I am running many Bayesian models in parallel and want to skip models that take longer than a certain amount of time (e.g., 10 seconds).
To do this, I wrapped rstanarm::stan_glm() inside R.utils::...
3
votes
2
answers
208
views
Can I throw a C++ exception in a Windows API callback function?
Suppose, I have a try/catch in the wWinMain() function, which calls some Windows API functions, e.g. CreateWindowExW(), GetMessageW(), TranslateMessage(), DispatchMessageW(). The Windows API will call ...
2
votes
0
answers
156
views
Why catch block is ignored, and std::terminate is invoked? [duplicate]
I have a program that works as expected if compiled by GCC, but behaves weirdly after porting to Visual Studio.
The program throws an exception from noexcept(false) destructor (I know that it is a bad ...
2
votes
1
answer
84
views
This 'onError' handler must return a value assignable to 'UserCredential', but ends without returning a value. Try adding a return statement
ArgumentError (Invalid argument(s) (onError): The error handler of Future.catchError must return a value of the future's type)
I get the above error when I log in with credentials that don't exist in ...
-2
votes
1
answer
116
views
PHP try-catch ineffective for mb_convert_encoding() function [duplicate]
I have the following code in a CLI PHP script. (The value in $mime_encoded_text actually comes from a message header, but for the sake of clarity, I have simplified here) :
$mime_encoded_text = "...
Advice
0
votes
4
replies
124
views
Does the finally block run when returning inside try, and what happens if finally also returns?
I have a question about how try/finally behaves when using return statements in C#.
Consider the following methods:
public int Test()
{
return 12;
}
public int Test2()
{
try
{
...
-8
votes
1
answer
160
views
Wrapping a method in a try-catch block but unsure where to declare a char variable
I have this method in my program, it is meant to register the gender of the user for later on in the program (with Male and Female as the only valid options):
public static void Main(string[] args)
{
...
0
votes
2
answers
101
views
Exporting warning messages using tryCatch() but returning different value
My question is similar to this one but that returns the error, and this one which has no answers. I want to catch errors (returning NA) and warnings (returning NaN) but saving the warning message for ...
-1
votes
1
answer
177
views
Correct usage of try and except(error) in python [duplicate]
I was wondering how was the correct usage of the try execpt/execpt(err) function in python and why it's raising up this error
UnboundLocalError: cannot access local variable 'player_move'
where it ...
2
votes
1
answer
106
views
How to handle Disposing of CryptoStream after exception occurs during decrypt
C# .Net Framework 4.8.
I am using CryptoStream Reader to decrypt an encrypted datastream within a Using {} block.
If the Key used for decryption is incorrect, the CryptoStream Reader throws an ...
-1
votes
1
answer
70
views
Catching errors of model in controller method
I have a controller method which I am using to change the status of the row data in the database. But I forget to mention status field in the model file. So the status was not changing in the database....
-2
votes
1
answer
205
views
How to create a file only once when it's needed?
I'm working on a Java utility. This utility should read some input files (one or several). Each input file contains three types of strings, representing an integer, a float, and a string. The utility ...