• Stars
    star
    12
  • Rank 1,597,372 (Top 32 %)
  • Language
    Go
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A go package that offers a try/catch statement block.

try

A go package that offers a try/catch statement block.

Documentation

Here is a sample program making use of the try package. In this sample, variables in scope are accessed to demonstrate how this package interacts with your program.

package main

import (
	"github.com/thestrukture/try"
	"fmt"
	"errors"
)


func main(){

	count := 0

	try.Run(func(){
		count++
		count++

		// Will perform an error check, panic will
		// not be invoked if the interface passed is nil.
		try.Throw(errors.New("Crashed!"))

		fmt.Println(count);
	}).Catch(func(e interface{}){

		fmt.Println("Error : ", e)

	}).Finally(func(){
		fmt.Println("Done")
	})
}