github.com/blend/go-sdk@v1.20220411.3/sh/fatal.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package sh
     9  
    10  import (
    11  	"fmt"
    12  	"os"
    13  )
    14  
    15  // Fatal exits the process with a given error.
    16  func Fatal(err error) {
    17  	if err != nil {
    18  		fmt.Fprint(os.Stderr, err.Error())
    19  		os.Exit(1)
    20  	}
    21  }
    22  
    23  // Fatalf exits the process with a given formatted message to stderr.
    24  func Fatalf(format string, args ...interface{}) {
    25  	fmt.Fprintf(os.Stderr, format, args...)
    26  	os.Exit(1)
    27  }