SlideShare a Scribd company logo
1 of 4
Download to read offline
Development with Go
- Manjitsing K. Valvi
Error Handling
● Unwanted or unexpected condition occurring in program is ERROR
● E.g. File creation error, DB connection error, out of bound memory access etc.
● Error handling in Golang is unconventional as compared to that of languages like
Javascript, Java and Python
● Golang represents errors using the built-in error interface type
type error interface {
Error() string
}
● Interface contains a single method Error() that returns an error message as a string
● The error is often returned as a second argument of the function, making use of multiple
value return
Error Handling
● Go does not have exceptions like many other programming languages
● Go uses “Defer, panic and recover" for error handling
● A defer statement is a mechanism used to defer a function by putting it into an
executed stack once the function that contains the defer statement has finished, either
normally by executing a return statement or abnormally panicking
● A panic statement signals Golang that your code cannot solve the current problem and it
therefore stops the normal execution flow of your code
● Panics can be recovered by calling the built-in recover function within a deferred
function in the function that is panicking. Recover will then end the current state of
panic and return the panic error value
References
● “The Go Programming Language ”,Alan A.A.Donovan,Brian W.Kernighan,Addison Wesley Publication

More Related Content

What's hot

Flutter Festivals GDSC ASEB | Introduction to Dart
Flutter Festivals GDSC ASEB | Introduction to DartFlutter Festivals GDSC ASEB | Introduction to Dart
Flutter Festivals GDSC ASEB | Introduction to DartSadhanaParameswaran
 
A Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVMA Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVMCharles Anderson
 
Why should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming ParadigmWhy should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming ParadigmTech Triveni
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional waynluaces
 
Jsx language-notes
Jsx language-notesJsx language-notes
Jsx language-notesGoro Fuji
 
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)PROIDEA
 
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017Codemotion
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget coursecrazyaxe
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional wayThoughtworks
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈d0nn9n
 
The Practice of Programming - Notation
The Practice of Programming - NotationThe Practice of Programming - Notation
The Practice of Programming - NotationJuggernaut Liu
 
Boosting python web apps with protocol buffers & grpc
Boosting python web apps with protocol buffers & grpcBoosting python web apps with protocol buffers & grpc
Boosting python web apps with protocol buffers & grpcNaren Arya
 
An Introduction to Bazel
An Introduction to BazelAn Introduction to Bazel
An Introduction to BazelMatt Turner
 
Boosting individual feedback with AutoFeedback
Boosting individual feedback with AutoFeedbackBoosting individual feedback with AutoFeedback
Boosting individual feedback with AutoFeedbackAntonio García-Domínguez
 
Adopting language server for apache camel feedback from a java/Eclipse plugi...
Adopting language server for apache camel  feedback from a java/Eclipse plugi...Adopting language server for apache camel  feedback from a java/Eclipse plugi...
Adopting language server for apache camel feedback from a java/Eclipse plugi...Aurélien Pupier
 
Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...Baltasar García Perez-Schofield
 
Javascript Intro 01
Javascript Intro 01Javascript Intro 01
Javascript Intro 01vikram singh
 
Groovy as a Dynamic Language
Groovy as a Dynamic LanguageGroovy as a Dynamic Language
Groovy as a Dynamic LanguageDarren Cruse
 

What's hot (20)

Flutter Festivals GDSC ASEB | Introduction to Dart
Flutter Festivals GDSC ASEB | Introduction to DartFlutter Festivals GDSC ASEB | Introduction to Dart
Flutter Festivals GDSC ASEB | Introduction to Dart
 
A Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVMA Shallow Survey of Alternative Languages on the JVM
A Shallow Survey of Alternative Languages on the JVM
 
Why should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming ParadigmWhy should a Java programmer shifts towards Functional Programming Paradigm
Why should a Java programmer shifts towards Functional Programming Paradigm
 
Kotlin & arrow: the functional way
Kotlin & arrow:  the functional wayKotlin & arrow:  the functional way
Kotlin & arrow: the functional way
 
Ruby in mule
Ruby in muleRuby in mule
Ruby in mule
 
Groovy demo
Groovy demoGroovy demo
Groovy demo
 
Jsx language-notes
Jsx language-notesJsx language-notes
Jsx language-notes
 
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
 
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017
My 10 favorite Haxe language features - Francis Bourre - Codemotion Rome 2017
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget course
 
Kotlin & Arrow the functional way
Kotlin & Arrow the functional wayKotlin & Arrow the functional way
Kotlin & Arrow the functional way
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
 
The Practice of Programming - Notation
The Practice of Programming - NotationThe Practice of Programming - Notation
The Practice of Programming - Notation
 
Boosting python web apps with protocol buffers & grpc
Boosting python web apps with protocol buffers & grpcBoosting python web apps with protocol buffers & grpc
Boosting python web apps with protocol buffers & grpc
 
An Introduction to Bazel
An Introduction to BazelAn Introduction to Bazel
An Introduction to Bazel
 
Boosting individual feedback with AutoFeedback
Boosting individual feedback with AutoFeedbackBoosting individual feedback with AutoFeedback
Boosting individual feedback with AutoFeedback
 
Adopting language server for apache camel feedback from a java/Eclipse plugi...
Adopting language server for apache camel  feedback from a java/Eclipse plugi...Adopting language server for apache camel  feedback from a java/Eclipse plugi...
Adopting language server for apache camel feedback from a java/Eclipse plugi...
 
Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...Post-graduate course: Object technology: Implementation of object-oriented pr...
Post-graduate course: Object technology: Implementation of object-oriented pr...
 
Javascript Intro 01
Javascript Intro 01Javascript Intro 01
Javascript Intro 01
 
Groovy as a Dynamic Language
Groovy as a Dynamic LanguageGroovy as a Dynamic Language
Groovy as a Dynamic Language
 

Similar to Error handling (20)

Golang introduction
Golang introductionGolang introduction
Golang introduction
 
Go, meet Lua
Go, meet LuaGo, meet Lua
Go, meet Lua
 
go language- haseeb.pptx
go language- haseeb.pptxgo language- haseeb.pptx
go language- haseeb.pptx
 
Debuggers in system software
Debuggers in system softwareDebuggers in system software
Debuggers in system software
 
Advantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworksAdvantages of golang development services & 10 most used go frameworks
Advantages of golang development services & 10 most used go frameworks
 
Go lang
Go langGo lang
Go lang
 
Why golang
Why golangWhy golang
Why golang
 
Why golang
Why golangWhy golang
Why golang
 
Jsp applet
Jsp appletJsp applet
Jsp applet
 
Php exceptions
Php exceptionsPhp exceptions
Php exceptions
 
Go programming language
Go programming languageGo programming language
Go programming language
 
Let's Go: Introduction to Google's Go Programming Language
Let's Go: Introduction to Google's Go Programming LanguageLet's Go: Introduction to Google's Go Programming Language
Let's Go: Introduction to Google's Go Programming Language
 
Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language Lets Go - An introduction to Google's Go Programming Language
Lets Go - An introduction to Google's Go Programming Language
 
Go programing language
Go programing languageGo programing language
Go programing language
 
Fundamentals of Golang
Fundamentals of GolangFundamentals of Golang
Fundamentals of Golang
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
Golang workshop
Golang workshopGolang workshop
Golang workshop
 
Scaling applications with go
Scaling applications with goScaling applications with go
Scaling applications with go
 
compiler vs interpreter
compiler vs interpretercompiler vs interpreter
compiler vs interpreter
 
Comparing C and Go
Comparing C and GoComparing C and Go
Comparing C and Go
 

More from Manjitsing Valvi

Digital marketing marketing strategies for digital world
Digital marketing  marketing strategies for digital worldDigital marketing  marketing strategies for digital world
Digital marketing marketing strategies for digital worldManjitsing Valvi
 
Digital marketing channels
Digital marketing channelsDigital marketing channels
Digital marketing channelsManjitsing Valvi
 
Digital marketing techniques
Digital marketing techniquesDigital marketing techniques
Digital marketing techniquesManjitsing Valvi
 
Social media marketing & managing cybersocial campaign
Social media marketing & managing cybersocial campaignSocial media marketing & managing cybersocial campaign
Social media marketing & managing cybersocial campaignManjitsing Valvi
 
Creating marketing effective online store
Creating marketing effective online storeCreating marketing effective online store
Creating marketing effective online storeManjitsing Valvi
 
Social media marketing tech tools and optimization for search engines
Social media marketing   tech tools and optimization for search enginesSocial media marketing   tech tools and optimization for search engines
Social media marketing tech tools and optimization for search enginesManjitsing Valvi
 
Digital marketing managing cybersocial campaign
Digital marketing managing cybersocial campaignDigital marketing managing cybersocial campaign
Digital marketing managing cybersocial campaignManjitsing Valvi
 

More from Manjitsing Valvi (16)

Composite types
Composite typesComposite types
Composite types
 
Basic types
Basic typesBasic types
Basic types
 
Basic constructs ii
Basic constructs  iiBasic constructs  ii
Basic constructs ii
 
Basic constructs i
Basic constructs  iBasic constructs  i
Basic constructs i
 
Introduction to golang
Introduction to golangIntroduction to golang
Introduction to golang
 
Pointers & functions
Pointers &  functionsPointers &  functions
Pointers & functions
 
Operators
OperatorsOperators
Operators
 
Methods
MethodsMethods
Methods
 
Digital marketing marketing strategies for digital world
Digital marketing  marketing strategies for digital worldDigital marketing  marketing strategies for digital world
Digital marketing marketing strategies for digital world
 
Digital marketing channels
Digital marketing channelsDigital marketing channels
Digital marketing channels
 
Digital marketing techniques
Digital marketing techniquesDigital marketing techniques
Digital marketing techniques
 
Social media marketing & managing cybersocial campaign
Social media marketing & managing cybersocial campaignSocial media marketing & managing cybersocial campaign
Social media marketing & managing cybersocial campaign
 
Creating marketing effective online store
Creating marketing effective online storeCreating marketing effective online store
Creating marketing effective online store
 
Social media marketing tech tools and optimization for search engines
Social media marketing   tech tools and optimization for search enginesSocial media marketing   tech tools and optimization for search engines
Social media marketing tech tools and optimization for search engines
 
Digital marketing managing cybersocial campaign
Digital marketing managing cybersocial campaignDigital marketing managing cybersocial campaign
Digital marketing managing cybersocial campaign
 
Social media marketing
Social media marketingSocial media marketing
Social media marketing
 

Recently uploaded

247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 

Recently uploaded (20)

247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 

Error handling

  • 1. Development with Go - Manjitsing K. Valvi
  • 2. Error Handling ● Unwanted or unexpected condition occurring in program is ERROR ● E.g. File creation error, DB connection error, out of bound memory access etc. ● Error handling in Golang is unconventional as compared to that of languages like Javascript, Java and Python ● Golang represents errors using the built-in error interface type type error interface { Error() string } ● Interface contains a single method Error() that returns an error message as a string ● The error is often returned as a second argument of the function, making use of multiple value return
  • 3. Error Handling ● Go does not have exceptions like many other programming languages ● Go uses “Defer, panic and recover" for error handling ● A defer statement is a mechanism used to defer a function by putting it into an executed stack once the function that contains the defer statement has finished, either normally by executing a return statement or abnormally panicking ● A panic statement signals Golang that your code cannot solve the current problem and it therefore stops the normal execution flow of your code ● Panics can be recovered by calling the built-in recover function within a deferred function in the function that is panicking. Recover will then end the current state of panic and return the panic error value
  • 4. References ● “The Go Programming Language ”,Alan A.A.Donovan,Brian W.Kernighan,Addison Wesley Publication