Blockchain

How to Handle Different Types of Errors in Hyper-ledger Fabric Blockchain

IBM-hyperledger-blockchain

Blockchain isn’t the future — it’s now! Many industries and technology giants have started their ventures in blockchain technology and things will surely become bigger in the upcoming years. It’s also likely that you’ve started developing something based on the blockchain. We mean, if you are a coder who wants to keep track of the changes, you would have started with blockchain tech.

As it happens with development in other areas of technology, blockchain development is also prone to errors. You may have encountered a few such errors in the past. Thankfully, many blockchain development platforms now have dedicated methods for error handling and management. Hyperledger Fabric would be one of those options, you know.

Anyway, in this article, we will be talking about the different types of errors in blockchain development. Of course, they come in almost the same categories that you have seen in other programming languages. Major methods of handling these errors, however, is quite different when compared to normal coding. We’ll start with the different types of errors, then.

Ibm-blockchain-errors

1. Network-based Errors

Network-based errors are quite common when it comes to blockchain development. At the core, blockchain is about one of the biggest networks in the world. Even the slightest network error can have an impact on how your blockchain-powered application is going to function in the real world. One of the easiest methods to avoid this is by ensuring the proper installation and starting of the network. You will have to take all the steps according to the network you have. Don’t worry, we have an example from Hyperledger Fabric here.

Example 1:

Error: Error trying to ping. Error: 2 UNKNOWN: make sure the chaincode test-registry has been successfully instantiated and try again: could not find chaincode with name ‘test-registry’

The error means that there is some constraint in connecting with the network. As we said earlier, you have to install the network properly. Once that’s done, you have to enter the following code for starting network activity.

2. Database Errors

As it goes without saying, the blockchain tech is based on some of the significant databases. During each line of code, data from different databases may be pulled and put to use. If you encounter database errors while coding for blockchain, you should be much alarmed, you know. The first step is to make sure that there are no corruptions in the database set. Next step, you need to ensure the proper connection between the system and the data.

Example:

It deals with some of the issues in the database. The system was not able to interact with the same. One of the common fixes for the issue was:

By dropping the index (transaction_chaincode_proposal_input_idx) on the table transactions.  You could use the following script for doing this:

Error-handling-ibm-hyperledger

3. HTTP/API Errors

As the name says, these errors occur when there is something wrong with the server connection or the API that is being used. Depending on the type of error that occurs, certain codes are given for each type. In the world of the world wide web, for instance, HTTP Error 404 means that the page has not been found. Similarly, it is possible to find other types of errors in blockchain development as well.

Example 1:

            Error: Network Not found issue

As you can see, the system cannot find the network, which is causing the error. In order to fix this,

You will have to visit ./peer-base.yaml and make changes to the entry named,

After this, you will have to clean the docker containers. Once you are done, you can go ahead and rebuild.

Example 2:   

This error is observed when there is something wrong with the provided permissions. Also, there may be conflicts between two containers.

The solution is to kill the containers and restart.

4. Runtime Errors

You would also have come across runtime errors while dealing with Hyperledger or other types of blockchain development tech. The fact about this type of errors is that you can find a huge number of them, regardless of the coding framework that you are using. If you see one of these errors, it means that there is something wrong with the process of runtime.

Example 1:

It will be retried for the next request.

The probable solution for this error would be the following:

Example 2:

ERROR: network composer_default id b1067bdec4ca1800510fc9cc1f5d3500736e48920693b03831df0d8d8472ffac has active endpoints

This error normally occurs when you are trying to run two fabric servers at the same time. That is, you might have started the new fabric server without actually turning the first one off.

The solution, the simple one, is to turn off the earlier server and continue with the newer one.

Error Handling in Blockchain Frameworks

Let’s take the case of IBM Cloud Code, for instance.

There are in-built options to set up throwing and catching errors by default. This will make it really easy for a coder to understand and represent the potential errors in the system. The best part is that the performance of the API will not be affected by this.

Similarly, coming to the latest release of Hyperledger Fabric Code, it has a specific set of codes for displaying error codes. There is a vendor package that is used for generation and display of the errors. Since the docs are available for access, understanding and implementing the changes are also easy.

The Bottom Line

Apparently, these are the major types of errors that you would find in the Blockchain. As we said earlier, there is some error handling tech in frameworks. As a programmer, you should know about these errors and try your best to clean the code — so that these errors don’t occur.

Saurabh
Saurabh Mukhekar is a Tech Blogger from Pune, India. He is also thinker, maker, life long learner, hybrid developer, edupreneur, mover & shaker. He's captain planet of BlogSaays and seemingly best described in rhyme. Follow Him On
You may also like
IBM Developer Day 2019
IBM Developer Day 2019 Accelerating Blockchain, AI & Cloud Computing
Blockchain For Developers: Is it Right for Your Application?
2 Comments
  • Chris Charlie Jan 5,2019 at 2:11 pm

    Such a great informative post.Thank you for sharing this with us. Keep posting!

    • Saurabh Jan 7,2019 at 4:34 pm

      Hope this will help you to understand error handling in your blockchain programs

Leave Your Comment

Your Comment*

Your Name*
Your Webpage

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Pin It on Pinterest

Share This