Skip to content

Commit

Permalink
Merge pull request #35 from kostyabet/dev
Browse files Browse the repository at this point in the history
PR # 11 Error Handler Create
  • Loading branch information
kostyabet authored Dec 22, 2024
2 parents 965ceb7 + 8b3b716 commit 5cce0bb
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 25 deletions.
3 changes: 2 additions & 1 deletion File/Log/Log.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ getScoresCountSignal LogString 10, '===================================', 10, 'G
currentPointsSignal LogString 10, 'Current Points = '
addNewScoreSignal LogString 10, '===================================', 10, 'Add new score', 10
getUserScoreSignal LogString 10, '===================================', 10, 'Get user scores', 10
getBestScoreSignal LogString 10, '===================================', 10, 'Get best scores', 10
getBestScoreSignal LogString 10, '===================================', 10, 'Get best scores', 10
errorSignal LogString 10, '===================================', 10, 'ERROR FROM SERVER!', 10
15 changes: 15 additions & 0 deletions Server/SendRequest/Methods/Player.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ proc Server.Methods.Player.IsExist uses eax ebx
stdcall Log.Console, sendString, sendString.size
stdcall Log.Console, playerJSON.loginStart, sizeof.PlayerJSON
stdcall Server.SendRequest.GetIsPlayerExist, playerJSON.loginStart, sizeof.PlayerJSON, idResponseBuffer, [idResponseBufferLength]
cmp eax, -1
je .serverError
stdcall Log.Console, serverAnswer, serverAnswer.size
mov ebx, eax
stdcall File.IniFile.StrLen, eax
Expand All @@ -35,6 +37,9 @@ proc Server.Methods.Player.IsExist uses eax ebx
jmp .exit
@@:
mov eax, 1
jmp .exit
.serverError:
stdcall Log.Console, errorSignal, errorSignal.size
.exit:
stdcall ClearBuffer, [jsonLink]
ret
Expand Down Expand Up @@ -67,6 +72,8 @@ proc Server.Methods.Player.AddNewPlayer
stdcall Log.Console, sendString, sendString.size
stdcall Log.Console, playerJSON.loginStart, sizeof.PlayerJSON
stdcall Server.SendRequest.PostAddPlayers, playerJSON.loginStart, sizeof.PlayerJSON, idResponseBuffer, [idResponseBufferLength]
cmp eax, -1
je .serverError
stdcall Log.Console, serverAnswer, serverAnswer.size
mov ebx, eax
stdcall File.IniFile.StrLen, eax
Expand Down Expand Up @@ -106,6 +113,9 @@ proc Server.Methods.Player.AddNewPlayer
mov [str_error], str_nullerror
stdcall Server.ErrorPayloadUpdate ; null error
stdcall Page.ChangePage, LoadingPage
jmp .exit
.serverError:
stdcall Log.Console, errorSignal, errorSignal.size
.exit:
stdcall ClearBuffer, [jsonLink]
ret
Expand All @@ -124,6 +134,8 @@ proc Server.Methods.Player.ScoresCount
stdcall Log.Console, sendString, sendString.size
stdcall Log.Console, idJSON.idStart, sizeof.IdJSON
stdcall Server.SendRequest.GetUserScoresCount, idJSON.idStart, sizeof.IdJSON, idResponseBuffer, [idResponseBufferLength]
cmp eax, -1
je .serverError
stdcall Log.Console, serverAnswer, serverAnswer.size
mov ebx, eax
stdcall File.IniFile.StrLen, eax
Expand All @@ -143,6 +155,9 @@ proc Server.Methods.Player.ScoresCount
jmp .exit
@@:
stdcall Server.JSON.GetScoresCount, [jsonLink]
jmp .exit
.serverError:
stdcall Log.Console, errorSignal, errorSignal.size
.exit:
stdcall ClearBuffer, [jsonLink]
ret
Expand Down
15 changes: 15 additions & 0 deletions Server/SendRequest/Methods/Score.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ proc Server.Methods.Score.Add
stdcall Log.Console, sendString, sendString.size
stdcall Log.Console, scoreJSON.pointsStart, sizeof.ScoreJSON
stdcall Server.SendRequest.PostAddScores, scoreJSON.pointsStart, sizeof.ScoreJSON, idResponseBuffer, [idResponseBufferLength]
cmp eax, -1
je .serverError
stdcall Log.Console, serverAnswer, serverAnswer.size
mov ebx, eax
stdcall File.IniFile.StrLen, eax
stdcall Log.Console, ebx, eax
xchg eax, ebx
mov [jsonLink], eax
jmp .exit
.serverError:
stdcall Log.Console, errorSignal, errorSignal.size
.exit:
stdcall ClearBuffer, [jsonLink]
ret
Expand All @@ -37,6 +42,8 @@ proc Server.Methods.Score.UserScores
stdcall Log.Console, sendString, sendString.size
stdcall Log.Console, idJSON.idStart, sizeof.IdJSON
stdcall Server.SendRequest.GetAllUserScores, idJSON.idStart, sizeof.IdJSON, scoresUserRespBuffer, [scoresUserRespBufferLength]
cmp eax, -1
je .serverError
stdcall Log.Console, serverAnswer, serverAnswer.size
mov ebx, eax
stdcall File.IniFile.StrLen, eax
Expand All @@ -59,6 +66,9 @@ proc Server.Methods.Score.UserScores
@@:
stdcall Server.JSON.ParseUserScore, [jsonLink], [UserScores]
mov [UserScoresLen], eax
jmp .exit
.serverError:
stdcall Log.Console, errorSignal, errorSignal.size
.exit:
stdcall ClearBuffer, [jsonLink]
ret
Expand All @@ -71,6 +81,8 @@ proc Server.Methods.Score.BestScores
stdcall Log.Console, getBestScoreSignal, getBestScoreSignal.size
stdcall Log.Console, sendString, sendString.size
stdcall Server.SendRequest.GetBestScores, 0, 0, scoresGlobRespBuffer, [scoresGlobRespBufferLength]
cmp eax, -1
je .serverError
stdcall Log.Console, serverAnswer, serverAnswer.size
mov ebx, eax
stdcall File.IniFile.StrLen, eax
Expand All @@ -92,6 +104,9 @@ proc Server.Methods.Score.BestScores
@@:
stdcall Server.JSON.ParseBestScore, [jsonLink], [BestScores]
mov [BestScoresLen], eax
jmp .exit
.serverError:
stdcall Log.Console, errorSignal, errorSignal.size
.exit:
stdcall ClearBuffer, [jsonLink]
ret
Expand Down
24 changes: 12 additions & 12 deletions Server/SendRequest/REST/GET.asm
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ proc Server.SendRequest.GET,\

mov eax, [buffer]
mov [result], eax
;invoke MessageBox, 0, eax, ErrorTitle, MB_OK

jmp .exit
.error:
invoke GetLastError
invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK
mov [result], -1
invoke GetLastError
;invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK
.exit:
cmp [hRequest], 0
jz .skipRequest
invoke WinHttpCloseHandle, [hRequest]
cmp [hRequest], 0
jz .skipRequest
invoke WinHttpCloseHandle, [hRequest]
.skipRequest:

cmp [hConnect], 0
jz .skipConnect
invoke WinHttpCloseHandle, [hConnect]
cmp [hConnect], 0
jz .skipConnect
invoke WinHttpCloseHandle, [hConnect]
.skipConnect:

cmp [hSession], 0
jz .skipSession
invoke WinHttpCloseHandle, [hSession]
cmp [hSession], 0
jz .skipSession
invoke WinHttpCloseHandle, [hSession]
.skipSession:
mov eax, [result]
ret
Expand Down
24 changes: 12 additions & 12 deletions Server/SendRequest/REST/POST.asm
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,26 @@ proc Server.SendRequest.POST,\

mov eax, [buffer]
mov [result], eax
;invoke MessageBox, 0, eax, ErrorTitle, MB_OK
jmp .exit
.error:
invoke GetLastError
invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK
mov [result], -1
invoke GetLastError
;invoke MessageBox, 0, ErrorMessage, ErrorTitle, MB_OK
.exit:
cmp [hRequest], 0
jz .skipRequest
invoke WinHttpCloseHandle, [hRequest]
cmp [hRequest], 0
jz .skipRequest
invoke WinHttpCloseHandle, [hRequest]
.skipRequest:

cmp [hConnect], 0
jz .skipConnect
invoke WinHttpCloseHandle, [hConnect]
cmp [hConnect], 0
jz .skipConnect
invoke WinHttpCloseHandle, [hConnect]
.skipConnect:

cmp [hSession], 0
jz .skipSession
invoke WinHttpCloseHandle, [hSession]
cmp [hSession], 0
jz .skipSession
invoke WinHttpCloseHandle, [hSession]
.skipSession:
mov eax, [result]
ret
Expand Down

0 comments on commit 5cce0bb

Please sign in to comment.