exception-handling

netTCP binding Soap Security Negotiation Failed

最后都变了- 提交于 2019-12-12 08:22:46
问题 I am writing a WCF service requires impersonate and session. It is ok when I tried to call it on my local machine, but on the remote machine it always failed with such error: Security Support Provider Interface (SSPI) authentication failed. The server may not be running in an account with identity 'host/hostname'. If the server is running in a service account (Network Service for example), specify the account's ServicePrincipalName as the identity in the EndpointAddress for the server. If the

Why Kotlin receives such an UndeclaredThrowableException rather than a ParseException?

我的未来我决定 提交于 2019-12-12 08:20:41
问题 I have an extension method that converts string to Date in Kotlin. fun String.convertToDate() : Date { var pattern: String = "dd-mm-yyyy" val dateFormatter = SimpleDateFormat(pattern) return dateFormatter.parse(this) // parse method throw ParseException } And this is the code where I am trying to catch possible exception. try { "22---2017".convertToDate() } catch (ex: ParseException) { // ParseException supposed to be caught in this block logger.error("Parse exception occur") } catch (ex:

How to catch (and ignore) a call to the error function?

一世执手 提交于 2019-12-12 08:19:09
问题 I'm surprised I couldn't find an answer to this anywhere. I'm writing a roguelike and I'm using the ncurses library from hackage, which is a pretty good wrapper around the ncurses library. Now ncurses has this quirk where if you try to write the bottom right character, it does so, then it tries to move the cursor to the next character, then it fails because there's nowhere to move it to. It returns an error value that you can only ignore. My problem is that the haskell ncurses library writer

Ensure Objective-C Code Execution Before Cocoa Application Exits

倾然丶 夕夏残阳落幕 提交于 2019-12-12 08:12:30
问题 Assume that a cocoa app must execute some vitally important objective-c operation before it exits (for any reason—crash or quit). Is it possible to ensure the execution of arbitrary objective-c code in response to every crash event? ( SIGINT , SIGBUS , SIGSEGV , etc, ignoring the "uncatchables" ( SIGSTOP , SIGKILL , bolt of lightning, etc.)) It would be helpful to know what your hooks are trying to do. For example: let's say that for the app to operate, it absolutely must change the value of

What is an alternative to exceptions for flow control?

耗尽温柔 提交于 2019-12-12 08:10:08
问题 I inherited a java application that processes requests and throws an exception if it determines a request should be cancelled. Exceptions have been convenient for the previous developer because they are an easy way to exit out of a tree of logic that no longer applies (yes a goto) and it prints a stack trace to the log which is good info to have. It seems to be the consenus on forums and blogs that exceptions should not be used for flow control and over half of the requests processed are

Exception Handling in C - What is the use of setjmp() returning 0?

感情迁移 提交于 2019-12-12 08:08:22
问题 I have a few questions relating to setjmp/longjmp usage - What is the use of setjmp(jmp___buf stackVariables) returning 0. It is a default, which we cannot influence. Is the only significance of setjmp(stackVariables) is to push the stack in stackVariables. And basically 0 tells us if the stack was pushed on stack_variables successfully. Their is one occasion when the value is non-zero (any non-zero) when you return from a longjmp. What is returning from a lomgjmp, when do you return from

Is finally block really necessary for the clean up code (like closing streams)?

徘徊边缘 提交于 2019-12-12 07:52:03
问题 I am very confused as to why do I need to need to put the clean-up code like closing streams in a finally block. I've read that the code in finally block will run no matter what (whether there's an exception); and after the finally block runs, the rest of the method continues. My question is: if the rest of the method has to continue then why don't I put the clean-up code after my try/catch block in a function? 回答1: The finally block will always run if an uncaught exception is thrown, but the

Where do I handle asynchronous exceptions?

喜欢而已 提交于 2019-12-12 07:51:45
问题 Consider the following code: class Foo { // boring parts omitted private TcpClient socket; public void Connect(){ socket.BeginConnect(Host, Port, new AsyncCallback(cbConnect), quux); } private void cbConnect(IAsyncResult result){ // blah } } If socket throws an exception after BeginConnect returns and before cbConnect gets called, where does it pop up? Is it even allowed to throw in the background? 回答1: Code sample of exception handling for asynch delegate from msdn forum. I beleive that for

How to treat exceptions in constructor best?

巧了我就是萌 提交于 2019-12-12 07:16:43
问题 How to treat exception in best way in construct? option1 - catch exception where object created: class Account { function __construct($id){ if(empty($id)){ throw new My_Exception('id can\'t be empty'); } // ... } } class a1 { function just($id){ try { $account = new Account($id); } catch(Exception $e){ $e->getMessage(); } } class a2{ function just($id){ try { $account = new Account($id); } catch(Exception $e){ $e->getMessage(); } } option2 : catch exception inside __construct class Account{

ELMAH vs Enterprise Library Exception Handling Block

一个人想着一个人 提交于 2019-12-12 07:13:58
问题 My team is currently in the process of building an ASP.NET MVC application, and we're trying to decide which of these frameworks to implement to deal with error handling and logging. What are the reasons for choosing one of these over the other? 回答1: Personally, I've been using Enterprise Library for a number of our clients and I have yet to use ELMAH. Here's my thoughts on Ent Lib. It will take you a bit to get up to speed with Ent Lib - it's not a 5 second install and start using it thing.