// New returns an error with the supplied message.
// New also records the stack trace at the point it was called.
funcNew(codevtrpcpb.Code,messagestring)error{
return&fundamental{
msg:message,
code:code,
stack:callers(),
}
}
// New creates a new error using the code and input string.
funcNew(codevtrpcpb.Code,instring)error{
ifcode==vtrpcpb.Code_OK{
panic("OK is an invalid error code; use INTERNAL instead")
}
return&vtError{
code:code,
err:in,
// NewWithoutCode returns an error when no applicable error code is available
// It will record the stack trace when creating the error
funcNewWithoutCode(messagestring)error{
return&fundamental{
msg:message,
code:vtrpcpb.Code_UNKNOWN,
stack:callers(),
}
}
// Wrap wraps the given error, returning a new error with the given message as a prefix but with the same error code (if err was a vterror) and message of the passed error.
// Wrapf wraps the given error, returning a new error with the given format string as a prefix but with the same error code (if err was a vterror) and message of the passed error.