exception-handling

Static linking libgcc on Windows DLL

筅森魡賤 提交于 2019-12-12 03:31:26
问题 I am writing a Windows DLL in C++. This library has only C interface and uses only standard Windows libraries which also have C interface. Therefore it seems me safe to statically link all C++ libraries into the library because I am not dependent on C++ ABI version when using C interfaces only. Unfortunately when I compile my library with -static-stdc++ -static-libgcc , my library stops handling exceptions and when some exception is thrown, the DLL calls its statically linked _Unwind

Exception message not being shown if json_encode is applied to the output

旧街凉风 提交于 2019-12-12 02:53:38
问题 Here's the code: try{ //The exception is thrown. throw new Exception('Parâmetros de consulta inválidos'); // and in the catch block it's caught successfully: }catch(Exception $e){ echo $e->getMessage(); //This prints the message correctly. $output = json_encode(array('msg'=>$e->getMessage())); echo $output; //But this fails...displays {"msg":null} } What is the issue here? 回答1: The problem is with the character â and á. Infact, if you replace them with a simple a, you'll get the right message

Why wont my program execute the second catch block, when the error exists?

混江龙づ霸主 提交于 2019-12-12 02:49:34
问题 I am new to try/catch exception handling, and am wondering why my second catch block will not execute. The sec variable should not be between 0-59, so I'd like it to say "invalid second entry", but it doesn't. Thank you! #include <stdexcept> #include <iostream> #include <string> using namespace std; class BadHourError : public runtime_error { public: BadHourError() : runtime_error("") {} }; class BadSecondsError : public runtime_error { public: BadSecondsError() : runtime_error("") {} };

Turtle window exit errors

无人久伴 提交于 2019-12-12 02:46:09
问题 When I click out of my turtle window it spits 24 lines of errors to the shell. The error report ends with turtle.Terminator . turtle.Terminator is not an exception so I can't handle it with try-except . Is there a base class for all turtle exceptions so I can get rid of these errors? 回答1: You want to use the window's native close button (eg. the red X in OSX) to close the window while your turtle code is running. You end up with lots of error messages to the terminal. The following approach

Spring ResponseEntityExceptionHandler and original POST payload

倾然丶 夕夏残阳落幕 提交于 2019-12-12 02:43:16
问题 I'm using ResponseEntityExceptionHandler in a Spring Boot -based application, to capture errors in a single place and output a consistent error payload. Everything works as expected. ResponseEntityExceptionHandler has a method handleHttpMessageNotReadable that can be used to "react" on a client sending an invalid message (in my case a JSON payload). Again, everything works as expected. If a client POST an invalid JSON document, the code in the handleHttpMessageNotReadable is executed

Customized 404 error page in spring-boot

≡放荡痞女 提交于 2019-12-12 02:24:54
问题 I am trying to create a custom error page for invalid URL in SpringMvc (Spring-boot version 1.5.1). In order to disable the default whitelabel error page I have: application.properties spring.thymeleaf.cache=false server.error.whitelabel.enabled=false spring.mvc.throw-exception-if-no-handler-found=true spring.resources.add-mappings=false My exception handler is: RestResponseEntityExceptionHandler.java @ControllerAdvice public class RestResponseEntityExceptionHandler extends

Handling exception logging in a Java task scheduler program?

别说谁变了你拦得住时间么 提交于 2019-12-12 02:14:25
问题 I need to design a Task Scheduler Where 1) User should be able to schedule multiple task at the same time. 2) There should be proper error handling on failure of any task and should not affect the other running tasks. I found the related programme at http://www.roseindia.net/java/example/java/util/CertainAndRepeatTime.shtml My concern is about handling of point 2 in program provided at above link. Say I schedule a recurring mail send process in above program which will be run first time on 12

Exception handling code review in spring

时光毁灭记忆、已成空白 提交于 2019-12-12 02:02:48
问题 I am developing spring-mvc application. Below steps I am doing to handle exception in the code. Wrapping the exception in WrapperException in the catch block (along with some extra details for debugging) and throwing it back to the caller method. Finally handling WrapperException in controller. But the problem with above approach is my method contains large amount of code for exception wrapping and throwing it back. Is it the accepted behavior? or should I change my approach? My

Django exception handling cancels non-atomic transaction mode

浪尽此生 提交于 2019-12-12 01:56:35
问题 Best described by example. Consider the following code ( Django 1.9 ) View: @transaction.non_atomic_requests def error_generating_view(request): modelA = ModelA(...) modelA.save() if (some_bad_condition) return json_error_msg ('Some custom message') return HttpResponse(True) View in other module def json_error_msg(error_message): return JsonResponse(json.dumps(error_message, ensure_ascii=False), status = 500, safe = False) Django seems to through an exception to client-side, but the problem

Selenium webdriver explicit wait for alert throws UnhandledAlertException

无人久伴 提交于 2019-12-12 01:47:48
问题 I have to wait explicitly for 20 seconds for presence of an alert. If alert is not present after 20 seconds, I should throw an exception. Following is my wait for alert, but it throws unhandled Alert Exception before 20 seconds. Can someone help me on this? try { new WebDriverWait(driver, 20).ignoring(NoAlertPresentException.class) .ignoring(UnhandledAlertException.class) .until(ExpectedConditions.alertIsPresent()); } catch (Exception e) { } 回答1: How about writing your own ExpectedConditions