render_error替换成tip_exception

This commit is contained in:
xiaoxiaoqiong 2022-05-30 10:25:43 +08:00
parent 17fb43cea8
commit 6448a30e03
5 changed files with 38 additions and 38 deletions

View File

@ -14,12 +14,12 @@ class Ci::CloudAccountsController < Ci::BaseController
def create
flag, msg = check_bind_cloud_account!
return render_error(msg) if flag === true
return tip_exception(msg) if flag === true
ActiveRecord::Base.transaction do
@cloud_account = bind_account!
if @cloud_account.blank?
render_error('激活失败, 请检查你的云服务器信息是否正确.')
tip_exception('激活失败, 请检查你的云服务器信息是否正确.')
raise ActiveRecord::Rollback
else
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
@ -27,17 +27,17 @@ class Ci::CloudAccountsController < Ci::BaseController
end
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def activate
return render_error('请先认证') unless current_user.ci_certification?
return tip_exception('请先认证') unless current_user.ci_certification?
begin
@cloud_account = Ci::CloudAccount.find params[:id]
ActiveRecord::Base.transaction do
if @repo
return render_error('该项目已经激活') if @repo.repo_active?
return tip_exception('该项目已经激活') if @repo.repo_active?
@repo.activate!(@project)
else
@repo = Ci::Repo.auto_create!(@ci_user, @project)
@ -50,7 +50,7 @@ class Ci::CloudAccountsController < Ci::BaseController
end
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
end
@ -59,39 +59,39 @@ class Ci::CloudAccountsController < Ci::BaseController
def bind
flag, msg = check_bind_cloud_account!
return render_error(msg) if flag === true
return tip_exception(msg) if flag === true
ActiveRecord::Base.transaction do
@cloud_account = bind_account!
if @cloud_account.blank?
render_error('激活失败, 请检查你的云服务器信息是否正确.')
tip_exception('激活失败, 请检查你的云服务器信息是否正确.')
raise ActiveRecord::Rollback
else
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
end
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def trustie_bind
account = params[:account].to_s
return render_error("account不能为空.") if account.blank?
return tip_exception("account不能为空.") if account.blank?
flag, msg = check_trustie_bind_cloud_account!
return render_error(msg) if flag === true
return tip_exception(msg) if flag === true
ActiveRecord::Base.transaction do
@cloud_account = trustie_bind_account!
if @cloud_account.blank?
render_error('激活失败, 请检查你的云服务器信息是否正确.')
tip_exception('激活失败, 请检查你的云服务器信息是否正确.')
raise ActiveRecord::Rollback
else
current_user.set_drone_step!(User::DEVOPS_UNVERIFIED)
end
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def unbind
@ -107,18 +107,18 @@ class Ci::CloudAccountsController < Ci::BaseController
render_ok
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def oauth_grant
password = params[:password].to_s
return render_error('你输入的密码不正确.') unless current_user.check_password?(password)
return tip_exception('你输入的密码不正确.') unless current_user.check_password?(password)
oauth = current_user.oauths.last
return render_error("服务器出小差了.") if oauth.blank?
return tip_exception("服务器出小差了.") if oauth.blank?
result = gitea_oauth_grant!(password, oauth)
return render_error('授权失败.') unless result === true
return tip_exception('授权失败.') unless result === true
current_user.set_drone_step!(User::DEVOPS_CERTIFICATION)
end

View File

@ -30,7 +30,7 @@ class Ci::PipelinesController < Ci::BaseController
ActiveRecord::Base.transaction do
size = Ci::Pipeline.where('branch=? and identifier=? and owner=?', params[:branch], params[:repo], params[:owner]).size
if size > 0
render_error("#{params[:branch]}分支已经存在流水线!")
tip_exception("#{params[:branch]}分支已经存在流水线!")
return
end
pipeline = Ci::Pipeline.new(pipeline_name: params[:pipeline_name], file_name: params[:file_name],owner: params[:owner],
@ -53,7 +53,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok({id: pipeline.id})
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
# 在代码库创建文件
@ -118,7 +118,7 @@ class Ci::PipelinesController < Ci::BaseController
end
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def destroy
@ -132,7 +132,7 @@ class Ci::PipelinesController < Ci::BaseController
end
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def content
@ -182,7 +182,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def update_stage
@ -192,7 +192,7 @@ class Ci::PipelinesController < Ci::BaseController
end
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def delete_stage
@ -205,7 +205,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def update_stage_index(pipeline_id, show_index, diff)
@ -229,7 +229,7 @@ class Ci::PipelinesController < Ci::BaseController
unless steps.empty?
steps.each do |step|
unless step[:template_id]
render_error('请选择模板!')
tip_exception('请选择模板!')
return
end
if !step[:id]
@ -246,7 +246,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def create_stage_step
@ -262,7 +262,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def update_stage_step
@ -279,7 +279,7 @@ class Ci::PipelinesController < Ci::BaseController
render_ok
end
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def delete_stage_step
@ -289,6 +289,6 @@ class Ci::PipelinesController < Ci::BaseController
end
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
end

View File

@ -30,12 +30,12 @@ class Ci::ProjectsController < Ci::BaseController
@file = interactor.result
render_result(1, "更新成功")
else
render_error(interactor.error)
tip_exception(interactor.error)
end
end
def activate
return render_error('你还未认证') unless current_user.ci_certification?
return tip_exception('你还未认证') unless current_user.ci_certification?
begin
ActiveRecord::Base.transaction do
@ -60,7 +60,7 @@ class Ci::ProjectsController < Ci::BaseController
end
def deactivate
return render_error('该项目已经取消激活') if !@repo.repo_active?
return tip_exception('该项目已经取消激活') if !@repo.repo_active?
@project.update_column(:open_devops, false)
@repo.deactivate_repos!

View File

@ -20,14 +20,14 @@ class Ci::SecretsController < Ci::BaseController
if result["id"]
render_ok
else
render_error(result["message"])
tip_exception(result["message"])
end
else
result = Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], options).create_secret
if result["id"]
render_ok
else
render_error(result["message"])
tip_exception(result["message"])
end
end
end
@ -39,7 +39,7 @@ class Ci::SecretsController < Ci::BaseController
Ci::Drone::API.new(@ci_user.user_hash, ci_drone_url, params[:owner], params[:repo], {name: name}).delete_secret
render_ok
else
render_error("参数名不能为空")
tip_exception("参数名不能为空")
end
rescue Exception => ex
render_ok

View File

@ -50,7 +50,7 @@ class Ci::TemplatesController < Ci::BaseController
end
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def update
@ -63,7 +63,7 @@ class Ci::TemplatesController < Ci::BaseController
)
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
def destroy
@ -73,7 +73,7 @@ class Ci::TemplatesController < Ci::BaseController
end
render_ok
rescue Exception => ex
render_error(ex.message)
tip_exception(ex.message)
end
#======流水线模板查询=====#