exception-handling

The proper way to do exception handling

孤人 提交于 2019-12-11 16:18:11
问题 Now what I generally do when writing code is something like this function changeBookAuthor(int $id, string $newName){ if(!$newName){ throw new MyAppException('No author name was provided'); } $book = Books::find($id); if(!$book){ throw new MyAppException('The provided book id could not be found'); } } in the laravel doc we see: https://laravel.com/docs/5.4/errors public function report(Exception $exception) { if ($exception instanceof CustomException) { // } return parent::report($exception);

Python LIRC blocking Signal workaround not working

纵然是瞬间 提交于 2019-12-11 16:16:05
问题 I've been having trouble with the Python LIRC function lirc.nextcode() . I turned off blocking, which allows the code lirc.nextcode() to be skipped if the LIRC queue is empty, by initializing with lirc.init("program", blocking=False) and tried lirc.set_blocking(False, sockid) . Neither worked and the code would always hang, waiting for a button press, when it should continue on. I found this workaround that puts a time limit on raw_input('prompt') . So even if my lirc.nextcodde() waits for a

Apache Camel CXF empty response when handling exception

走远了吗. 提交于 2019-12-11 16:14:03
问题 This question is related to the previous one : Apache Camel multicast, exception and Aggregation strategy I think I missunderstood the problem when asking the previous question. I try to handle exception I thrown in my route. .filter(not(successResponsePredicate)) .to("log:com.sdmo.Error?level="+LOG_LEVEL) .transform(simple("Erreur lors de l'appel copyItem")) .process(new ConvertCartResponseProcessor()) .throwException(new Exception("copyItemError")) .end() The exception is handled through

Android: my application won't run because I need to handle an unknownhostexception. when i do it crashes

夙愿已清 提交于 2019-12-11 16:11:23
问题 Im writing an Android application that needs to access data stored in a mongodb data base. In my on create method I keep on getting an "UnknownHostException" error. I have added the internet permission to my manifest file, restarted my developing machine, and applied a try/catch. Now, the application crashes when I run it (right as the application is opened). When I used the class I wrote for the database (CrumbsDb) outside of android, it works as intended. Please help. Sorry if my question

How to re-connect to MongoDB using C++ driver?

筅森魡賤 提交于 2019-12-11 15:33:19
问题 I've a C++ function which saves a document to MongoDB using C++ driver. It takes connection reference as argument: http://pastebin.com/jwRDhNWQ When I restart MongoDB, I can see that new connection is being made. However, conn.isFailed() remains true. This maybe happening due to the fact that when I reconnect, I am using conn and not &conn When I do use &conn as in &conn.connect("localhost"); , I get error message- error: lvalue required as unary ‘&’ operand How do I fix this? i.e. modify the

Why instance variable inside Custom Exception Mapper has to be static?

孤人 提交于 2019-12-11 15:13:04
问题 I have implemented a custom exception mapper in order to throw the bad request in my application. Here's the code: CustomFilterBadRequest: package com.test.exceptions; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.ext.ExceptionMapper; import java.util.Date; public class CustomFilterBadRequest extends Exception implements ExceptionMapper<CustomFilterBadRequest> { private String uriInfo; public CustomFilterBadRequest() { super("Invalid Request. Please

how to throw unhanded exceptions from flash active x controller callback

给你一囗甜甜゛ 提交于 2019-12-11 14:43:23
问题 i have written a application for improve the software quality used the Crashrpt api for windows. i have tried to integrate the api with My application.Basically i m using flash Active x shockwave object class for Loading swf file. if any exception is raised from WinApp its throwing the exceptions able to catch the report.if any kind of Exception is reised in flash call back method.its not able to process and not able to thrown the exception.i tried with ::SetUnhandledExceptionFilter

Handling errors and exceptions on the iPhone

ぃ、小莉子 提交于 2019-12-11 14:18:10
问题 I am developinga Core Data app for the iPhone, and I am new to the whole platform etc. My question is, how much should I look for and handle errors and exceptions, for example when opening up the persistent store. Looking at the "Locations" Core Data Tutorial for example (hope its OK to quote it here like this): (Se comments in the code for some of my conserns) - (void)applicationDidFinishLaunching:(UIApplication *)application { ... NSManagedObjectContext *context = [self managedObjectContext

ASP MVC N-Tier Exception handling

我是研究僧i 提交于 2019-12-11 14:09:46
问题 I am writing a service layer which uses Entity framework to get/set data from the database, and then pass it to an MVC web application. I am not able to decide what is the bext way to return database errors to the web application. Should I throw an exception and the web application can handle it accordingly, or should I return a string/bool to convey that the database action has worked or not? Any suggestion on what is the best practice? Thanks 回答1: You can either not handle them in your

Struts 2 - how to pass exceptions globally to a single action file from other action files

◇◆丶佛笑我妖孽 提交于 2019-12-11 14:08:21
问题 I want to pass exceptions globally to a single action file called ErrorAction , say from Index action. Here's my struts.xml file: <global-results> <result name="myErrorHandler" type="redirectAction"> <param name="actionName">myError</param> </result> <result name="login" type="tiles"> login </result> </global-results> <global-exception-mappings> <exception-mapping exception="java.lang.Exception" result="myErrorHandler" /> </global-exception-mappings> <action name="myError" class="com.actions