try-catch

try catch not working in recursive function

早过忘川 提交于 2019-12-25 07:48:04
问题 Objective What i am trying to do is catch the "Failed to load resource" error and put it in an alert window. Issue I am trying to catch a video that does not exist. Try catch is not catching the exception. Background I am trying to play through an array of videos, i continue to the next video when the previous one finishes. The issue is there wont always be a video for every element in the array. I have tried placing the try catch around just the play function. I have also tried placing the

Graphaware neo4j-php-client | Cannot catch Neo4jException

孤人 提交于 2019-12-25 04:16:02
问题 I'm using Postgresql + Neo4j for my project. I need to rollback postgres queries if neo4j query has failed. So, I need to catch Neo4jException in my code. But couldn't done yet. Thanks for help. require_once('pgconnect.php'); try{ $conn->beginTransaction(); //some pgsql code $conn->commit(); require_once('neoconnect.php'); $result = $client->run("a query"); $conn = null; } catch(PDOException $e){ require_once('pgrollback.php'); } this is my working code. But as you can see I don't have a

File processing using try-catch C++

僤鯓⒐⒋嵵緔 提交于 2019-12-25 03:43:21
问题 I'm working on a project about file processing. The users input ID, hours, and payrate. The output will be ID, hours, payrate and grosspay. I got those parts done. I really need help on try and catch, where users input a non-numeric, the project rejects and ask users to input again. Here what I got so far: #include <iostream> #include <fstream> #include <string> #include <cstdlib> #include <iomanip> #include "File.h" #include <exception> using namespace std; void File::Create() { ofstream

Handle Automapper exception?

ⅰ亾dé卋堺 提交于 2019-12-25 02:46:26
问题 Using mvc5 with automapper I have following: In Controller : [HttpPost] public ActionResult LunchMenu_Create_Index(VmSysMenuCreate menu) { try { var domainMenu = Mapper.Map<VmSysMenuCreate, Menu>(menu); } catch (Exception ex) { return Content("Error msg"); } return Content("Succes"); } Mapping: Mapper.CreateMap<VmSysMenuCreate, Menu>() .ForMember(c => c.Id, op => op.MapFrom(v => v.Id)) .ForMember(c => c.MenuDate, op => op.ResolveUsing(data => { try { DateTime convertedDate = Convert

Catch fails on connection to Mongo

人盡茶涼 提交于 2019-12-25 01:46:09
问题 the answer to this question: How to get node to exit when mongo connect fails contains async/wait code for a connection however, my code (running on node v11.5.0 and mongodb v3.1.13) is failing to catch: (async function() { let db; try { db = await MongoClient.connect(uri, { useNewUrlParser: true }); console.log("RETURN", db); } catch (err) { console.log('EXITING'); process.exit(1); } }()); to prove the point I intentionally give a uri without credentials: mongodb://undefined@cluster0-shard

What is passed the the function in a Promise .catch block?

若如初见. 提交于 2019-12-25 01:25:11
问题 What's the general difference between these two styles of handling .catch blocks in Promises: ... .catch(e => myMethod(e)) ... .catch(myMethod) What does a Promise's .catch pass to the receiving method? e.g. Can there be additional arguments? 回答1: In both cases, there is only one argument. There's no fundamental difference between these two styles, except that an arrow function behaves differently than a real function , especially this will be undefined or window (depending on whether strict

Trying to prompt the user to re-enter from the catch block, but the catch block terminates?

好久不见. 提交于 2019-12-25 00:53:11
问题 I am trying to write a program to ask a user to enter their age and prompt them to re-enter if they enter an improper value (such as a negative number, older than 120, an age with special characters or letters, an out of range number etc...) I tried writing a try/catch to ask the user to re-enter their age: System.out.println("Enter your age (a positive integer): "); int num; try { num = in.nextInt(); while (num < 0 || num > 120) { System.out.println("Bad age. Re-enter your age (a positive

Does the .NET JIT optimize nested try/catch statements?

依然范特西╮ 提交于 2019-12-24 21:24:56
问题 I've been thinking about nested try/catch statements and started to think about under which conditions, if any, the JIT can perform an optimization or simplification of the compiled IL. To illustrate, consider the following functionally-equivalent representations of an exception handler. // Nested try/catch try { try { try { foo(); } catch(ExceptionTypeA) { } } catch(ExceptionTypeB) { } } catch(ExceptionTypeC) { } // Linear try/catch try { foo(); } catch(ExceptionTypeA) { } catch

How to correctly trap and read any errors generated in a Promise.all call? [duplicate]

丶灬走出姿态 提交于 2019-12-24 19:27:59
问题 This question already has answers here : Wait until all promises complete even if some rejected (17 answers) Closed 10 months ago . I currently have a node.js/graphql micro service that uses Promise.all to call another micro service via apolloFetch. My Promise.all part seems to be working ok but I'm trying to have the error logging part working. I need to make sure that the Promise.all executes ALL THE PROMISES and not quit after it encounters the first error. Once it executes ALL THE

Correct use of Try Catch for the SQL connection in C#

别说谁变了你拦得住时间么 提交于 2019-12-24 18:51:43
问题 Is this code correct in means of Try/Catch? I need to value whether the action is done or not to inform the user about the result, so I will then get the bool value to know if connection was successful. public static bool CreateSQLDatabaseTable() { var connString = "Server=localhost\\SQLEXPRESS;Integrated Security = SSPI; database = MyDB"; string cmdText = "SELECT count(*) as Exist from INFORMATION_SCHEMA.TABLES where table_name =@Product"; try { using (var sqlConnection = new SqlConnection