exception-handling

WCF Service exception error when try to host in ASP.NET Web Site

随声附和 提交于 2019-12-10 10:13:42
问题 The following error occurs when trying to browse my .svc file. An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.NullReferenceException: Object reference not set to an instance of an object. at System.ServiceModel.Description.WsdlExporter.CreateWsdlBindingAndPort(ServiceEndpoint endpoint, XmlQualifiedName wsdlServiceQName, Port& wsdlPort, Boolean& newBinding, Boolean& bindingNameWasUniquified) at System.ServiceModel.Description.WsdlExporter

Calculated properties do not throw exceptions in Powershell. What are the workaround possibilities?

风格不统一 提交于 2019-12-10 10:04:06
问题 Apparently there is a by design quirk in Powershell that prevents exceptions that are thrown inside a Calculated Property Expression from bubbling up. All that happens is the value of the Calculated Property ends up being null. function Get-KBValue() { # Some Logic here that can throw an exception } .... Get-ChildItem C:\Test | Select-Object Name, CreationTime, @{Name="Kbytes"; Expression={ Get-KBValue }} If the Get-KBValue function throws an exception then the value of the Kbytes property is

@ExceptionHandler for Error gets called only if there's no mapping for Exception

北城以北 提交于 2019-12-10 09:53:40
问题 Using spring-web-4.2.6, I have the following Controller and ExceptionHandler: @ControllerAdvice public class ExceptionsHandler { @ExceptionHandler(Exception.class) public ResponseEntity<ErrorDTO> HandleDefaultException(Exception ex) { ... } @ExceptionHandler(InternalError.class) public ResponseEntity<ErrorDTO> HandleInternalError(InternalError ex) { ... } } @RestController @RequestMapping("/myController") public class MyController { @RequestMapping(value = "/myAction", method = RequestMethod

Spring MVC ExceptionHandler for restful and normal

爱⌒轻易说出口 提交于 2019-12-10 09:50:26
问题 I want to handle exception for both normal and rest/ajax requests. Here is my code, @ControllerAdvice public class MyExceptionHandler { @ExceptionHandler(Exception.class) public ModelAndView handleCustomException(Exception ex) { ModelAndView model = new ModelAndView("error"); model.addObject("errMsg", ex.getMessage()); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); ex.printStackTrace(pw); sw.toString(); model.addObject("errTrace", sw); return model; }

Best place to store static error strings

那年仲夏 提交于 2019-12-10 09:48:05
问题 I was wondering if anyone had any input on the best practice of where to store static error strings in a C# application. I have a visual studio 2010 solution that has 5 projects and have defined several constant error messages to be returned via a WCF REST web service in the form of a message. My current errors I have defined (hard-coded) are in the following format (CODE, MESSAGE): 999 - Your request could not be processed with the parameters specified. I am not asking how to create custom

How to throw an exception by its run-time type?

拟墨画扇 提交于 2019-12-10 09:40:20
问题 I want to call a function that may throw an exception. If it does throw an exception, I want to catch it and pass the exception object to a handler function. The default implementation of the handler function is simply to throw the exception. Here is whittled-down code to illustrate the issue: struct base_exception : exception { char const* what() const throw() { return "base_exception"; } }; struct derived_exception : base_exception { char const* what() const throw() { return "derived

Catch-all exception handling for outbound ChannelHandler

社会主义新天地 提交于 2019-12-10 09:35:02
问题 In Netty you have the concept of inbound and outbound handlers. A catch-all inbound exception handler is implemented simply by adding a channel handler at the end (the tail) of the pipeline and implementing an exceptionCaught override. The exception happening along the inbound pipeline will travel along the handlers until meeting the last one, if not handled along the way. There isn't an exact opposite for outgoing handlers. Instead (according to Netty in Action, page 94) you need to either

What is an exception in PHP for and what is try and catch?

二次信任 提交于 2019-12-10 09:28:07
问题 I am pretty new to using object/classes in PHP and I am curious about EXCEPTIONS , TRY , and CATCH In the example below I have all 3 shown in use. Obviously an exception is some sort of way of triggering an error but I do not understand why? In the code below I could easily show some sort of error or something without the exception part there? Below that example is an example using try and catch. It appears to me to be the same as using if/else. I may be wrong, this is just the way I see them

Function exceptions specification and standard exceptions - foo() throw(Exception)

佐手、 提交于 2019-12-10 07:47:11
问题 In C++ you may declare function with exception specification like this: int foo() const throw(Exception); I found those two links: http://www.cplusplus.com/doc/tutorial/exceptions/ and http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8l.doc%2Flanguage%2Fref%2Fcplr156.htm But several things end up unanswered... Question 1: why to add exception specification? Will it bring any performance increase? What will be different for compiler? Because it seems

How can catched exception be null (not NullReferenceException)?

孤街醉人 提交于 2019-12-10 05:55:08
问题 I have run into a rather weird little problem. In the following code I can not understand how e can be null ; try { //Some Code here } catch (Exception e) { //Here e is null } As far as I know, throw null will be converted to throw new NullReferenceException() . The problem seems to be related to multithreading, as removing another thread also seems to fix it. Or at least I have only seen this when the above code is run in a new thread. The whole program uses many threads and is a bit complex