errores

package
v2.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2025 License: LGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Gestión de panics

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func PanicIfError

func PanicIfError(err error, params ...any)

Panic si error

Example
package main

import (
	"fmt"
	"strconv"

	"github.com/horus-es/go-util/v2/errores"
)

func main() {
	s := "42"
	k, err := strconv.Atoi(s)
	errores.PanicIfError(err, "La cadena %q no se puede convertir a entero", s)
	fmt.Println(k)
}
Output:

42

func PanicIfTrue

func PanicIfTrue(condition bool, msg string, params ...any)

Panic si condición

Example
package main

import (
	"fmt"

	"github.com/horus-es/go-util/v2/errores"
)

func main() {
	z := 2 * 3
	errores.PanicIfTrue(z != 6, "Error en multiplicación: 2x3=%d", z)
	fmt.Println(z)
}
Output:

6

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL