You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.4 KiB

// ------------------------------------------------------------------------
// Project active2
// Active Thing (activething.com) git.activething.com/go
//
// File name active.go
// Created by DEV
// Modified 12/04/2024
//
// Copyright 2024 activething.com
// ------------------------------------------------------------------------
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ------------------------------------------------------------------------
package fmx
import (
"ansi"
"errs/err_fmt"
"errs/stack"
"fmt"
"strings"
)
const (
fbBuildError string = "Error building error format for type '%v'. Check formatter configuration or consider handling unsupported error types gracefully. Error: %s"
fbUnwrapError string = "Error building error from wrapped error. Encountered type '%v'. Consider handling this type explicitly or providing a generic fallback message. Error: %s"
fbCauseError string = "Error formatting cause error. Encountered type '%v'. Review formatter logic for handling cause errors or provide a generic fallback message. Error: %s"
)
func defaultFrameBuilder(builder err_fmt.Builder, frame stack.Frame, num int) {
if strings.Index(frame.Package,"runtime") != -1 {
return
}
var c1, c2, c3, c4 ansi.Code
/*
if builder.Options().ShowAnsi(){
c1 = c1.SetFgColor(ansi.ColorBlue).SetBgColor(ansi.ColorHWhite)
c2 = c2.SetFgColor(ansi.ColorMagenta)
c3 = c3.SetFgColor(ansi.ColorWhite)
c4 = c3.SetStyle(ansi.StyleBold).SetFgColor(ansi.ColorHWhite)
}
*/
nm := c4.Sprintf(" %d ",num)
ln := c1.Sprintf(fmt.Sprintf("%-60s",fmt.Sprintf(" %s.%s", frame.Package, frame.FuncName)))
builder.AddText(fmt.Sprint(nm,ln))
builder.AddText(c2.Sprintf(" %.90s:%d", frame.File, frame.LineNumber))
f, e := frame.SourceLine()
if e == nil {
builder.AddText(c3.Sprintf(" %s\n", f))
} else {
//builder.AddText(c3.Sprintf(" error %s\n", e.Error()))
}
}

Powered by TurnKey Linux.