提交 72b09864 编写于 作者: programor_guo's avatar programor_guo

panic output detail info

上级 b1244c0a
......@@ -164,10 +164,10 @@ func init() {
// it will panic cannot find config/config.yaml
bytes, err := ioutil.ReadFile(Root + "/config/config.yaml")
if err != nil {
panic(err)
panic(err.Error())
}
if err = yaml.Unmarshal(bytes, &Config); err != nil {
panic(err)
panic(err.Error())
}
}
......@@ -35,14 +35,14 @@ func init() {
}
mgoSession, err := mgo.DialWithInfo(mgoDailInfo)
if err != nil {
panic(err)
panic(err.Error())
}
DB.mgoSession = mgoSession
DB.mgoSession.SetMode(mgo.Monotonic, true)
c := DB.mgoSession.DB(config.Config.Mongo.DBDatabase).C(cChat)
err = c.EnsureIndexKey("uid")
if err != nil {
panic(err)
panic(err.Error())
}
// redis pool init
......
......@@ -23,14 +23,14 @@ func initMysqlDB() {
db, err := gorm.Open("mysql", dsn)
if err != nil {
log.Error("", "", dsn)
panic(err)
panic(err.Error())
}
//Check the database and table during initialization
sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s ;", config.Config.Mysql.DBDatabaseName)
err = db.Exec(sql).Error
if err != nil {
panic(err)
panic(err.Error())
}
db.Close()
......@@ -38,7 +38,7 @@ func initMysqlDB() {
config.Config.Mysql.DBUserName, config.Config.Mysql.DBPassword, config.Config.Mysql.DBAddress[0], config.Config.Mysql.DBDatabaseName)
db, err = gorm.Open("mysql", dsn)
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable := "CREATE TABLE IF NOT EXISTS `user` (" +
......@@ -56,7 +56,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `friend` (" +
......@@ -69,7 +69,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `friend_request` (" +
......@@ -82,7 +82,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `black_list` (" +
......@@ -94,7 +94,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `user_black_list` (" +
......@@ -105,7 +105,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `group` (" +
......@@ -120,7 +120,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `group_member` (" +
......@@ -134,7 +134,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `group_request` (" +
......@@ -155,7 +155,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB AUTO_INCREMENT=38 DEFAULT CHARSET=utf8mb4;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
sqlTable = "CREATE TABLE IF NOT EXISTS `chat_log` (" +
......@@ -173,7 +173,7 @@ func initMysqlDB() {
" ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC;"
err = db.Exec(sqlTable).Error
if err != nil {
panic(err)
panic(err.Error())
}
}
......
......@@ -20,14 +20,14 @@ func NewKafkaConsumer(addr []string, topic string) *Consumer {
consumer, err := sarama.NewConsumer(p.addr, nil)
if err != nil {
panic(err)
panic(err.Error())
return nil
}
p.Consumer = consumer
partitionList, err := consumer.Partitions(p.Topic)
if err != nil {
panic(err)
panic(err.Error())
return nil
}
p.PartitionList = partitionList
......
......@@ -30,11 +30,11 @@ func NewMConsumerGroup(consumerConfig *MConsumerGroupConfig, topics, addr []stri
config.Consumer.Return.Errors = consumerConfig.IsReturnErr
client, err := sarama.NewClient(addr, config)
if err != nil {
panic(err)
panic(err.Error())
}
consumerGroup, err := sarama.NewConsumerGroupFromClient(groupID, client)
if err != nil {
panic(err)
panic(err.Error())
}
return &MConsumerGroup{
consumerGroup,
......@@ -47,7 +47,7 @@ func (mc *MConsumerGroup) RegisterHandleAndConsumer(handler sarama.ConsumerGroup
for {
err := mc.ConsumerGroup.Consume(ctx, mc.topics, handler)
if err != nil {
panic(err)
panic(err.Error())
}
}
}
......@@ -25,7 +25,7 @@ func NewKafkaProducer(addr []string, topic string) *Producer {
producer, err := sarama.NewSyncProducer(p.addr, p.config) //Initialize the client
if err != nil {
panic(err)
panic(err.Error())
return nil
}
p.producer = producer
......
......@@ -34,7 +34,7 @@ func loggerInit(moduleName string) *Logger {
//Close std console output
src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
if err != nil {
panic(err)
panic(err.Error())
}
writer := bufio.NewWriter(src)
logger.SetOutput(writer)
......@@ -82,7 +82,7 @@ func initRotateLogs(rotationTime time.Duration, maxRemainNum uint, level string,
rotatelogs.WithRotationCount(maxRemainNum),
)
if err != nil {
panic(err)
panic(err.Error())
} else {
return writer
}
......
......@@ -17,7 +17,7 @@ func init() {
// see https://gist.github.com/jniltinho/9787946#gistcomment-3019898
conn, err := net.Dial("udp", "8.8.8.8:80")
if err != nil {
panic(err)
panic(err.Error())
}
defer conn.Close()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册