import * as __F__ from 'lodash'

declare global {
    // 统一错误码定义
    const ERR$TODO: string
    const ERR$UNKNOWN: string
    const ERR$ASSERT: string
    const ERR$PARAM: string
    const ERR$CONFIG: string
    const ERR$UNAUTHORIZED: string
    const ERR$FORBIDDEN: string
    function xthrow(code?: string | Error, param?: any): void
    function xassert(expr: any, code?: string, param?: any): any
    // 对于异常内容的格式化参数解析处理成为四元组code/msg/param/stack
    function xerror(err: Error | string, param?: any): { msg: string, code: string, param, stack: string[] }
    // 用于获取错误栈的root cause根本原因（第一个被拦截的错误发生位置）
    function xroot(err: Error)
    // 获取异常调用栈用于辅助错误提示定位
    function xstack(err: Error, compact?: boolean)
    // 对于promise原生方法的底层异步方法调用的封装实现（解决三方callback嵌套问题）
    function xpromise(callback: (ok: (out?: any) => void, fail: (err: Error) => void) => Promise<any>): Promise<any>
    // 对代码块片段错误的拦截处理进行正确的错误转换处理
    // 第二个参数为空直接上报func错误透传，为ErrorCode进行错误转义，为回调进行进行错误捕获处理。
    function xcall<T>(func: Promise<T>, error_code_or_error_callback?: string | ((err: Error) => Promise<void>)): Promise<T>
    // 钉钉报警
    function xalert(param: Error | { [index: string]: any }): Promise<void>
}
