mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-06 13:14:11 +00:00
- Update go.mod module path from mhsanaei/3x-ui/v3 to saeederamy/3x-ui/v3 - Update all 73 Go files' import paths accordingly - Fix README.fa_IR.md install command to point to fork's main branch The fork was referencing the original repo's module path in go.mod and all Go source imports, making it dependent on MHSanaei's namespace at build time. https://claude.ai/code/session_01M6d5atbWjuLTj6UwRHoK5m
32 lines
754 B
Go
32 lines
754 B
Go
// Package common provides common utility functions for error handling, formatting, and multi-error management.
|
|
package common
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
|
|
"github.com/saeederamy/3x-ui/v3/logger"
|
|
)
|
|
|
|
// NewErrorf creates a new error with formatted message.
|
|
func NewErrorf(format string, a ...any) error {
|
|
msg := fmt.Sprintf(format, a...)
|
|
return errors.New(msg)
|
|
}
|
|
|
|
// NewError creates a new error from the given arguments.
|
|
func NewError(a ...any) error {
|
|
msg := fmt.Sprintln(a...)
|
|
return errors.New(msg)
|
|
}
|
|
|
|
// Recover handles panic recovery and logs the panic error if a message is provided.
|
|
func Recover(msg string) any {
|
|
panicErr := recover()
|
|
if panicErr != nil {
|
|
if msg != "" {
|
|
logger.Error(msg, "panic:", panicErr)
|
|
}
|
|
}
|
|
return panicErr
|
|
}
|