Files
beego/core/berror/pre_define_code.go
zeekay 6e545b9eef fork: beego v2.3.8 — prometheus/client_golang stripped (luxfi/metric backend)
Patches against upstream beego/[email protected]:
  server/web/admin_controller.go     — promhttp.Handler → luxfi/metric HTTP handler
  server/web/filter/prometheus/      — luxfi/metric backend, drops MustRegister
  client/httplib/filter/prometheus/  — luxfi/metric backend
  client/orm/filter/prometheus/      — luxfi/metric backend
  core/config/etcd/config.go         — drop grpc-ecosystem/go-grpc-prometheus
                                       interceptors (etcd dialing has no
                                       observability through this path)

Default closure: 0 grpc, 0 protobuf, 0 prometheus/client_golang.
Consumers in hanzoai/iam see the fork through workspace mode.
2026-05-22 20:59:15 -07:00

53 lines
1.5 KiB
Go

// Copyright 2021 beego
//
// 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 berror
import (
"fmt"
)
// pre define code
// Unknown indicates got some error which is not defined
var Unknown = DefineCode(5000001, "error", "Unknown", fmt.Sprintf(`
Unknown error code. Usually you will see this code in three cases:
1. You forget to define Code or function DefineCode not being executed;
2. This is not Beego's error but you call FromError();
3. Beego got unexpected error and don't know how to handle it, and then return Unknown error
A common practice to DefineCode looks like:
%s
In this way, you may forget to import this package, and got Unknown error.
Sometimes, you believe you got Beego error, but actually you don't, and then you call FromError(err)
`, goCodeBlock(`
import your_package
func init() {
DefineCode(5100100, "your_module", "detail")
// ...
}
`)))
func goCodeBlock(code string) string {
return codeBlock("go", code)
}
func codeBlock(lan string, code string) string {
return fmt.Sprintf("```%s\n%s\n```", lan, code)
}