443 questions
1
vote
1
answer
64
views
I'm catching errors, why does output look like it isn't
Here's my PowerShell 5.1 script to get service status on all machines. I'm giving each server 5 seconds to respond before moving on. However, it still looks like I'm getting the uncaught messages in ...
3
votes
1
answer
102
views
Doesn't my function cover all return paths or it is compiler's bug
I have the following function that worked until my recent update of the Visual Studio
2022 compiler (17.11.4). The error I get from the compiler is : not all code paths return a value. But which path ...
0
votes
1
answer
217
views
What would cause "class verified rejected" in Android developing with Java, when I turn on minifyEnable?
I have a class using try-catch-finally, and it works well in debug package. But when I turn on MinifyEnable, the app crashed with class verified rejected:
java.lang.VerifyError: Verifier rejected ...
1
vote
4
answers
976
views
Using Try-Catch-Finally to process code for API endpoint - What are the drawbacks?
I know this is bad design and I am trying to find any reason to not do this, so I need some help.
I have an API endpoint that is being hit and needs to respond back with an OK response within a few ...
1
vote
0
answers
41
views
Catch block not updating state in custom useFetch React hook [duplicate]
I have made the following custom useFetch hook for my Next.js app:
import HTTPMethod from "http-method-enum";
import { useState } from "react";
export default function useFetch() {...
1
vote
2
answers
5k
views
using try vs TryCatch in R
My R code is as follows
errors = 0
for(i in c(1:100)){
tryCatch(expr = {
API Call
}, error = {errors=errors+1}, finally = {})
further code
}
The code is meant to continue execution even ...
4
votes
1
answer
89
views
JavaScript try catch finally block change precedence of errors
Sometimes I have a code in try-catch-finally block when finally branch does some cleanup code which may throw an Error. An error in the finally branch suppresses a possible error in the main branch. I ...
-1
votes
1
answer
112
views
try/catch/finally Exception with System.exit(0)
try {
fruit fr = (fruit) p;
System.exit(0);
} catch (Exception e) {
System.out.println("not the right object");
} finally {
System.out.println("finablock");
}
...
0
votes
1
answer
129
views
Try/catch block in an infinity loop to print out something, if there is an infinity loop
this is my code (which is an infinity while loop. I should implement a try/catch block here, so that it stops, because it's going to infinity. My professor says we should implement a 'OutOfMemoryError'...
-4
votes
1
answer
94
views
try, except and finally in python [duplicate]
def finding(a,b):
try:
result=a+b
return result
except TypeError:
return "please type only num"
finally:
return "this line will get print at ...
1
vote
2
answers
438
views
Is it okay to call the the method a try catch statement is in with the finally block
I made a switch case statement menu with one of the options being System.exit(0);. This is all surrounded by a try, finally that calls the method all of this is in. Would you guys not recommend this ...
0
votes
1
answer
2k
views
Powershell Catch Error: Unable to find a default server with Active Directory Web Services running
Need help to catch the error. Whenever my network connection is unstable my get-ad script will be terminated.
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
$Date = Get-Date -Format ...
1
vote
0
answers
168
views
I can't reach the catch block of the try-catch method [duplicate]
I'm sending a base64 string to a backend with axios, but it can only be sent if the string is not over 2MB long.
if it's longer than that I want to console.log the error message, but it doesn't work - ...
0
votes
1
answer
241
views
scanner.close() Does not work when I use try/finally
import java.util.Scanner;
public class userInput
{
public static void main(String[]args){
try{
Scanner scanner = new Scanner(System.in);
String ...
0
votes
1
answer
70
views
I can't use NumberFormatExeption. The program should continue even if the user input a string or non-number
Guessing the number
import java.util.*;
public class LabExer5A
{
public static void main(String args[])
{
Scanner Input = new Scanner (System.in);
System.out.println(&...
2
votes
1
answer
7k
views
Use try-with-resources or close this 'Stream' in a "finally" clause [duplicate]
I am using Files.walk() to get some files from directory stuff but I am getting a warning about blocker bug from Sonarqube and Sonarlint code analysis that
Connections, streams, files, and other ...
0
votes
1
answer
53
views
Why can't function A catch the error thrown by function B
I'm doing try and catch exercises in JavaScript.
here is my code
function getTime1() {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(11111);
}, 1000);
...
1
vote
1
answer
525
views
finally block - variable cannot be resolved
Java 8
import java.util.zip.GZIPOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
private void createFile(final String json) throws IOException {
...
1
vote
1
answer
527
views
R: Errorhandling with tryCatchLog - create a customizable result code for the console and write a detailled traceback to log file
I have code that includes several initial checks of different parameter values. The code is part of a larger project involving several R scripts as well as calls from other environments. If a ...
1
vote
1
answer
189
views
Discuss how the finally block works
I am using Visual Studio 2019, and I have a piece of code that uses finally block, I have declared a std::string object at the beginning of each Test1(), Test2() and Test3() functions.
I put a break ...
0
votes
1
answer
54
views
How to return try block value in java even before finally block start executing?
I have code snippet in java like
Int methodHitByAPI() {
List returnValue = doSomething();
return returnValue;
finishProcess(returnValue);
}
My doubt is that i wanted to execute ...
0
votes
2
answers
308
views
How to ensure that a single finally block will be executed no matter what in a series of consecutive try...catch within the same method?
I want to execute a block of code even if ANY exception is caught in any of the preceding Try/Catch blocks, rather than having Finally blocks after every single Try/Catch. Is this possible to do?
...
0
votes
2
answers
492
views
How to use finally block when using try-catch in a while loop
I have a usecase , wherein I need to read each line from a csv file :
Each line has parameters for a function call.
And I call the function for each entry.
while(csvReader.readLine != null){
try {
...
0
votes
0
answers
307
views
When will a Try and Catch statement break you out of Try?
If I have multiple Codelines within a Try statement.
will it break me out as soon as 1 of them doesn't function?/through an error?
and if yes, will it ignore the rest of the code within the try ...
-2
votes
1
answer
427
views
Java: try-catch-resources with return and throw new statements [duplicate]
This is my cose:
private ResultSetType makeRequest() {
try (CloseableHttpResponse response = this.sendRequest(request)) {
String responseBody = IOUtils.toString(
response....