當前位置: 首頁>>代碼示例>>Golang>>正文


Golang errorlib.Error函數代碼示例

本文整理匯總了Golang中github.com/eaciit/errorlib.Error函數的典型用法代碼示例。如果您正苦於以下問題:Golang Error函數的具體用法?Golang Error怎麽用?Golang Error使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Error函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ResetFetch

func (c *Cursor) ResetFetch() error {
	var e error
	c.Connection().(*Connection).Close()
	e = c.Connection().(*Connection).Connect()

	if e != nil {
		return errorlib.Error(packageName, modCursor, "Restart Connection", e.Error())
	}

	c.headerColumn = c.Connection().(*Connection).headerColumn
	c.file = c.Connection().(*Connection).file
	c.reader = c.Connection().(*Connection).reader

	e = c.prepIter()
	if e != nil {
		return errorlib.Error(packageName, modCursor, "ResetFetch", e.Error())
	}

	// c.PrepareCursor()
	// if e != nil {
	// 	return errorlib.Error(packageName, modCursor, "Prepare Cursor", e.Error())
	// }

	return nil
}
開發者ID:Budianto55,項目名稱:dbox,代碼行數:25,代碼來源:csv_cursor.go

示例2: HasPartExec

func (q *Query) HasPartExec() error {
	var jsonString []byte
	var err error
	if q.hasNewSave {
		jsonString, err = json.MarshalIndent(q.sliceData, "", "  ")
		if err != nil {
			return errorlib.Error(packageName, modQuery+".Exec", "Has part exec Marshal JSON", err.Error())
		}
	} else if q.hasSave {
		lastJson := q.Connection().(*Connection).getJsonToMap
		var allJsonData toolkit.Ms
		allJsonData = append(lastJson, q.sliceData...)

		jsonString, err = json.MarshalIndent(allJsonData, "", "  ")
		if err != nil {
			return errorlib.Error(packageName, modQuery+".Exec", "Has part exec Marshal JSON", err.Error())
		}
	}

	err = ioutil.WriteFile(q.Connection().(*Connection).filePath, jsonString, 0666)
	if err != nil {
		return errorlib.Error(packageName, modQuery+".Exec", "Write file", err.Error())
	}
	return nil
}
開發者ID:satriasm,項目名稱:dbox,代碼行數:25,代碼來源:json_query.go

示例3: Search

func Search(s SshSetting, path string, isParseble bool, search string) (string, error) {
	if path == "" {
		return "", errorlib.Error("", "", "SEARCH", "Path is Undivined")
	}

	if search == "" {
		return "", errorlib.Error("", "", "SEARCH", "Search param is undivined")
	}

	cmd := ""

	if isParseble {
		cmd = fmt.Sprintf(SEARCH_PARAM, path, search)
	} else {
		cmd = fmt.Sprintf(SEARCH, path, search)
	}

	res, e := s.GetOutputCommandSsh(cmd)

	if e != nil {
		e = errorlib.Error("", "", "SEARCH", e.Error())
	}

	return res, e
}
開發者ID:eaciit,項目名稱:sshclient,代碼行數:25,代碼來源:nix-operations.go

示例4: Connect

func (c *Connection) Connect() error {
	c.Close()

	ci := c.Info()

	if ci == nil || ci.Host == "" {
		return errorlib.Error(packageName, modConnection, "Connect", "No connection info")
	}

	_, e := os.Stat(ci.Host)
	if ci.Settings != nil {
		if ci.Settings["newfile"] == true {
			if os.IsNotExist(e) {
				create, _ := os.Create(ci.Host)
				create.Close()
			}
		} else {
			if os.IsNotExist(e) {
				return errorlib.Error(packageName, modConnection, "Connect", "Create new file is false")
			}
		}
	} else if os.IsNotExist(e) {
		return errorlib.Error(packageName, modConnection, "Connect", "No json file found")
	}

	c.filePath = ci.Host

	defaultPath, fileName, sep := c.GetBaseFilepath()
	c.basePath = defaultPath
	c.baseFileName = fileName
	c.separator = sep

	return nil
}
開發者ID:haibudi,項目名稱:dbox,代碼行數:34,代碼來源:json_connection.go

示例5: List

func List(s SshSetting, path string, isParseble bool) (string, error) {
	if path == "" {
		return "", errorlib.Error("", "", "LIST", "Path is Undivined")
	}

	cmd := ""

	if isParseble {
		cmd = fmt.Sprintf(LIST_PARAM, path)
	} else {
		cmd = fmt.Sprintf(LIST, path)
	}

	res, e := s.GetOutputCommandSsh(cmd)

	if e != nil {
		e = errorlib.Error("", "", "LIST", e.Error())
	}

	startStr := strings.Index(res, "\n")

	if res != "" {
		return res[startStr:], e
	}

	return res, e
}
開發者ID:eaciit,項目名稱:sshclient,代碼行數:27,代碼來源:nix-operations.go

示例6: Chmod

func Chmod(s SshSetting, path string, permission string, format bool) (e error) {
	if format {
		permission, e = constructPermission(permission)
		if e != nil {
			return errorlib.Error("", "", "CHMOD", e.Error())
		}
	}

	if path == "" {
		return errorlib.Error("", "", "CHMOD", "Path is Undivined")
	}

	if permission == "" {
		return errorlib.Error("", "", "CHMOD", "Permission is Undivined")
	}

	cmd := fmt.Sprintf(CHMOD, permission, path)
	_, e = s.GetOutputCommandSsh(cmd)

	if e != nil {
		return errorlib.Error("", "", "CHMOD", e.Error())
	}

	return e
}
開發者ID:eaciit,項目名稱:sshclient,代碼行數:25,代碼來源:nix-operations.go

示例7: Remove

func Remove(s SshSetting, recursive bool, paths ...string) map[string]error {
	var es map[string]error

	if len(paths) < 1 {
		es[""] = errorlib.Error("", "", "REMOVE", "Paths is Undivined")
		return es
	}

	for _, path := range paths {
		cmd := ""
		if recursive {
			cmd = fmt.Sprintf(REMOVE_RECURSIVE, path)
		} else {
			cmd = fmt.Sprintf(REMOVE, path)
		}

		_, e := s.GetOutputCommandSsh(cmd)

		if e != nil {
			if es == nil {
				es = map[string]error{}
			}
			es[path] = errorlib.Error("", "", "REMOVE", e.Error())
		}
	}
	return es
}
開發者ID:eaciit,項目名稱:sshclient,代碼行數:27,代碼來源:nix-operations.go

示例8: MakeFile

func MakeFile(s SshSetting, content string, path string, permission string, format bool) error {
	if path == "" {
		return errorlib.Error("", "", "MAKEFILE", "Path is Undivined")
	}

	cmd := fmt.Sprintf(MKFILE, content, path)
	_, e := s.GetOutputCommandSsh(cmd)

	if e != nil {
		return errorlib.Error("", "", "MAKEFILE", e.Error())
	}

	if permission == "" {
		permission = "755"
		format = false
	}

	e = Chmod(s, path, permission, format)

	if e != nil {
		return errorlib.Error("", "", "MAKEFILE", e.Error())
	}

	return e
}
開發者ID:eaciit,項目名稱:sshclient,代碼行數:25,代碼來源:nix-operations.go

示例9: OpenSession

func (c *Connection) OpenSession() error {
	c.Close()

	t, e := os.OpenFile(c.filePath, os.O_RDWR, 0)
	if e != nil {
		return errorlib.Error(packageName, modConnection, "Open File", e.Error())
	}
	c.openFile = t

	i, e := ioutil.ReadFile(c.filePath)
	if e != nil {
		return errorlib.Error(packageName, modQuery+".Exec", "Read file", e.Error())
	}

	var hoomanJson []toolkit.M
	e = toolkit.Unjson(i, &hoomanJson)
	if e != nil {
		return errorlib.Error(packageName, modQuery+".Exec", "Cannot Unjson", e.Error())
	}

	c.lines = 0
	c.sData = ""
	c.sameId = false
	if len(hoomanJson) == 0 {
		c.isNewSave = true
	} else {
		c.getJsonToMap = hoomanJson
	}

	return nil
}
開發者ID:haibudi,項目名稱:dbox,代碼行數:31,代碼來源:json_connection.go

示例10: RdbmsConnect

func (c *Connection) RdbmsConnect(drivername string, stringConnection string) error {
	if drivername == "hive" {
		connInfo := strings.Split(stringConnection, ",")
		c.Hive = hive.HiveConfig(connInfo[0], connInfo[1], connInfo[2], connInfo[3], connInfo[4], connInfo[5])
		c.Drivername = drivername
		c.Hive.Conn.Open()
		e := c.Hive.Conn.TestConnection()
		if e != nil {
			return err.Error(packageName, modConnection, "Connect", e.Error())
		}
	} else {
		sqlcon, e := sql.Open(drivername, stringConnection)
		if e != nil {
			return err.Error(packageName, modConnection, "Connect", e.Error())
		}
		c.Sql = *sqlcon
		c.Drivername = drivername
		e = sqlcon.Ping()
		if e != nil {
			return err.Error(packageName, modConnection, "Connect", e.Error())
		}
	}
	if c.Info().Settings.Has("dateformat") {
		c.DateFormat = toolkit.ToString(c.Info().Settings.Get("dateformat", ""))
	}

	return nil
}
開發者ID:ranggaeaciit,項目名稱:dbox,代碼行數:28,代碼來源:rdbms_connection.go

示例11: Load

func (l *ConfigListBase) Load() error {
	e := l.Self().Validate()
	if e != nil {
		return e
	}

	if l.Self().NewItem() == nil {
		return err.Error(packageName, objConfigList, "Load", "No implementation of NewItem()")
	}

	fis, e := ioutil.ReadDir(l.configFolder)
	if e != nil {
		return err.Error(packageName, objConfigList, "Load", e.Error())
	}

	l.Inititems()
	for _, fi := range fis {
		item := l.Self().NewItem()
		e = NewFromFile(filepath.Join(l.configFolder, fi.Name()), item)
		if e == nil {
			l.Set(item)
		}
	}

	return nil
}
開發者ID:eaciit,項目名稱:configlist,代碼行數:26,代碼來源:cfglist.go

示例12: Chown

func Chown(s SshSetting, path string, user string, group string, recursive bool) error {
	if path == "" {
		return errorlib.Error("", "", "CHOWN", "Path is Undivined")
	}

	if user == "" {
		return errorlib.Error("", "", "CHOWN", "User is Undivined")
	}

	if group == "" {
		return errorlib.Error("", "", "CHOWN", "Group is Undivined")
	}

	cmd := ""

	if recursive {
		cmd = fmt.Sprintf(CHOWN_RECURSIVE, user, group, path)
	} else {
		cmd = fmt.Sprintf(CHOWN, user, group, path)
	}

	_, e := s.GetOutputCommandSsh(cmd)

	if e != nil {
		return errorlib.Error("", "", "CHOWN", e.Error())
	}

	return e
}
開發者ID:eaciit,項目名稱:sshclient,代碼行數:29,代碼來源:nix-operations.go

示例13: setConnectionFromConfigFile

func (d *DataContext) setConnectionFromConfigFile(name string) error {
	d.ConnectionName = name
	if d.ConnectionName == "" {
		d.ConnectionName = fmt.Sprintf("Default")
	}

	connType := strings.ToLower(config.Get("Connection_" + d.ConnectionName + "_Type").(string))
	host := config.Get("Connection_" + d.ConnectionName + "_Host").(string)
	username := config.Get("Connection_" + d.ConnectionName + "_Username").(string)
	password := config.Get("Connection_" + d.ConnectionName + "_Password").(string)
	database := config.Get("Connection_" + d.ConnectionName + "_database").(string)

	ci := new(dbox.ConnectionInfo)
	ci.Host = host
	ci.UserName = username
	ci.Password = password
	ci.Database = database

	conn, eConnect := dbox.NewConnection(connType, ci)
	if eConnect != nil {
		return err.Error(packageName, modCtx, "SetConnectionFromConfigFile", eConnect.Error())
	}
	if eConnect = conn.Connect(); eConnect != nil {
		return err.Error(packageName, modCtx, "SetConnectionFromConfigFile", eConnect.Error())
	}
	d.Connection = conn
	return nil
}
開發者ID:rinosukmandityo,項目名稱:orm,代碼行數:28,代碼來源:datacontext.go

示例14: Cursor

func (q *Query) Cursor(in toolkit.M) (dbox.ICursor, error) {
	var cursor *Cursor

	setting, e := q.prepare(in)
	if e != nil {
		return nil, err.Error(packageName, modQuery, "Cursor", e.Error())
	}

	commandtype := setting.GetString("commandtype")
	if commandtype != dbox.QueryPartSelect {
		return nil, err.Error(packageName, modQuery, "Cursor", "Cursor is only working with select command, for "+commandtype+" please use .Exec instead")
	}

	e = q.openFile()
	if e != nil {
		return nil, err.Error(packageName, modQuery, "Cursor", e.Error())
	}
	//toolkit.Printf("Data count: %d \n", len(q.data))
	cursor = newCursor(q)
	where := setting.Get("where", []*dbox.Filter{}).([]*dbox.Filter)
	if len(where) > 0 {
		cursor.where = where
		cursor.indexes = dbox.Find(q.data, where)
	}
	return cursor, nil
}
開發者ID:Budianto55,項目名稱:dbox,代碼行數:26,代碼來源:query.go

示例15: openFile

func (q *Query) openFile() error {
	if q.fileHasBeenOpened {
		return nil
	}

	_, e := os.Stat(q.jsonPath)
	if e != nil && (strings.Contains(e.Error(), "does not exist") || strings.Contains(e.Error(), "no such file or directory")) {
		q.data = []toolkit.M{}
		return nil
	} else if e != nil {
		return err.Error(packageName, modQuery, "openFile: Open file fail", e.Error())
	}
	bs, e := ioutil.ReadFile(q.jsonPath)
	if e != nil {
		return err.Error(packageName, modQuery, "openFile: Read file data fail", e.Error())
	}
	jsonText := string(bs)
	var tempData []toolkit.M
	e = toolkit.UnjsonFromString(jsonText, &tempData)
	if e != nil {
		return err.Error(packageName, modQuery, "openFile: Serializaion fail", e.Error())
	}
	q.data = tempData

	q.fileHasBeenOpened = true
	return nil
}
開發者ID:Budianto55,項目名稱:dbox,代碼行數:27,代碼來源:query.go


注:本文中的github.com/eaciit/errorlib.Error函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。