TMVCActiveRecord.CurrentConnection.StartTransaction;
  try
    //do
    TMVCActiveRecord.CurrentConnection.Commit;
    Render(201, 'Create Successfully', '');
  except
    on E: Exception do
    begin
      TMVCActiveRecord.CurrentConnection.Rollback;
      if E.Message.Contains('不能在对象 ''dbo.MOCTC'' 中插入重复键。') then
      begin
        raise EMVCException.Create('Slipcode already exists!', '', 0, 404);
      end
      else
        raise EMVCException.Create(E.Message, '', 0, 404);
    end;
  end;

 

posted on 2023-05-02 16:00  redhat588  阅读(41)  评论(0编辑  收藏  举报