Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Exception handling



  Custom C++ exception class creation

In standard C++, we can use try catch to catch and exception when something goes wrong. These are some built in exception support in C++. By including the #include , we can now catch exceptions in C++ programs. This actually helps us on debugging our code and reduce the maintenance work.However sometimes if we want to create our own custom exception class. What should we do?We should include the #include line and then extend the exception class and implement some methods as you like. The genera...

   C++,std,exception,custom exception,implementation     2012-03-04 09:58:18

  User experience : Exception handling

Exception handling is the process of handling emergencies or unpredictable operational errors. The specific time of the occurrence of unexpected events and the actual consequences of the specific situation are difficult to predict. How to handle this unexpected crisis is also related to the user experience of your users. Let's first look at how some famous products deal with unexpected exception encountered by users:1. Goodyear tires can automatically expand when leaking.Tire blast is one of the...

   User experience,Exception handling     2013-04-06 05:05:04

  Error handling in GoLang

Error handling is one of the must talked topics for any programming language. The program would be more reliable and stable if errors are handled properly and timely. Each programming language has its own way to handle error, this applies to GoLang as well. This post will discuss more about GoLang's error handling mechanism. Error handling Before talking more about GoLang's error handling, we can see how different programming languages are handling errors. C's error check The most direct way of ...

   GOLANG,ERROR HANDLING,FLUENT INTERFACE     2021-03-06 21:36:08

  A HTTPS client and HTTPS server demo in Java

In this post, I will create a HTTPS server and HTTPS client demo which can establish HTTPS communication between a server and a client using Java. This should be very useful when we want to test our understanding about SSL communication. We will use both a detailed SSL client and a simple HttpsURLConnection as the HTTPS client. Before creating the actual HTTPS server and HTTPS client, we first need to generate the keystore and truststore to be used by the server and client. To generate the keyst...

   SSL,HTTPS,JAVA,DEMO     2015-10-23 09:04:36

  try { return } finally {}

Do you know what value will be printed when following program is ran? class Test { public int aaa() { int x = 1; try { return ++x; } catch (Exception e) { } finally { ++x; } return x; } public static void main(String[] args) { Test t = new Test(); int y = t.aaa(); System.out.println(y); } } And before answering the above question, do you have answers to following questions? If ther...

   JAVA,JAVA INTERVIEW QUESTION     2016-09-26 08:06:28

  Break down defer statements in GoLang

Basic Concepts What are the characteristics of the deferred statement defer in Go language? When is it usually used? The deferred statement(defer statement) in Go language has the following characteristics: Deferred Execution: Deferred statements are executed before the function containing them exits, regardless of whether the function returns normally or encounters an exception. Last In, First Out (LIFO): If there are multiple deferred statements, they are executed in the order of last in, f...

   DEFER,GOLANG     2024-02-10 21:56:10

  What and what not to log while debugging

Log is a critical part of an application. It serves as an eye to the programmer on how the application is working while debugging. Especially for applications running on production environment, if the application encounters problem and the problem cannot be reproduced on other environments, log will be extremely useful. While log is essential, but developers have to log smartly. Because if don't put log smartly, you may not get what you want while debugging or you may get too many...

   PROGRAMMING,DEBUG,LOG,SUPPORT     2016-03-14 08:09:03

  Why exception would be thrown when deleting element while looping through HashMap in Java

HashMap and other Collection types are frequently used in Java application programming. This post will explain why exception would be thrown when deleting element with Map.remove() while looping through a Map using Iterator. This issue would also occur to other Collection types such as Set, List. Below is a sample code snippet demonstrating the exception thrown. Map<String,String> map = Collections.synchronizedMap(new TreeMap<String,String>()); map.put("key1","value1"); map.put("ke...

   JAVA,HASHMAP,CONCURRENTMODIFICATIONEXCEPTION     2018-06-30 12:49:09

  Using MemoryMappedBuffer to handle large file in Java

When handling large files, it will largely affect the process speed while using traditional FileInputStream, FileOutputStream or RandomAccessFile since they trigger lots of read and write operations. In Java NIO, a new way of handling large file is introduced which is to use MmeoryMappedBuffer to create memory mapped file. Memory-mapped I/O uses the filesystem to establish a virtual memory mapping from user space directly to the applicable filesystem pages. With a memory-mapped file, you can pre...

   JAVA,IO,NIO     2015-11-13 01:58:08

  Gracefully exiting from console programs in Ruby

Imagine you write a CLI program or a Rake task which loops through some data performing some work on it. You run it and then you remembered something. You’d love to kill the process with ctrl-c, but that will raise an exception somewhere in the loop. What you want is for the iteration to complete and then you want the program to quit. You could handle the Interrupt exception or add some conditions. But how about a cleaner and reusable way? No problem - you can trap signals, which...

   Ruby,Exit,Command window,Console,Graceful     2012-03-14 13:42:16