zoukankan      html  css  js  c++  java
  • error.go源码笔记

    package pingo

    import (
        "errors"
        "strings"
    )

    const (
        errorCodeConnFailed = "err-connection-failed"
        errorCodeHttpServe  = "err-http-serve"
    )

    // Error reported when connection to the external plugin has failed.
    type ErrConnectionFailed error

    // Error reported when the external plugin cannot start listening for calls.
    type ErrHttpServe error

    // Error reported when an invalid message is printed by the external plugin.
    type ErrInvalidMessage error

    // Error reported when the plugin fails to register before the registration
    // timeout expires.
    type ErrRegistrationTimeout error

    func parseError(line string) error {
        parts := strings.SplitN(line, ": ", 2)
        if parts[0] == "" {
            return nil
        }

        err := errors.New(parts[1])

        switch parts[0] {
        case errorCodeConnFailed:
            return ErrConnectionFailed(err)
        case errorCodeHttpServe:
            return ErrHttpServe(err)
        }

        return err
    }
  • 相关阅读:
    webpack性能优化-PWA(离线访问技术)
    node增删改查
    webpack性能优化
    webpack常见配置
    第一个node接口
    $refs的解释
    vue路由传参的三种基本方式
    结构体的定义
    gcc 的编译流程 和gdb的调试方法
    makefile高级用法
  • 原文地址:https://www.cnblogs.com/zhangboyu/p/7457530.html
Copyright © 2011-2022 走看看