Update Utils.lua

This commit is contained in:
IBims2CooleTim 2023-09-30 23:26:40 +02:00 committed by GitHub
parent 57020c6b24
commit d1bfaf3ccf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,14 +4,14 @@ local EntryError = require(script.Parent.Errors.Entry)
local HttpService = game:GetService("HttpService") local HttpService = game:GetService("HttpService")
function errorHandler(type: string, resultBody: any, resultObject: {}) function fehlerMisshandlung(type: string, resultBody: any, resultObject: {})
local Error; local Error;
if typeof(resultBody) == typeof({}) and resultBody["message"] then if typeof(resultBody) == typeof({}) and resultBody["message"] then
Error = resultBody["message"] Error = resultBody["message"]
elseif typeof(resultBody) == typeof("") then elseif typeof(resultBody) == typeof("") then
Error = resultBody Error = resultBody
else else
Error = "An Unexpected Error occoured." Error = "Es ist ein unerwarteter Fehler aufgetreten."
end end
if type == "collection" then if type == "collection" then
@ -37,7 +37,7 @@ end
local utils = {} local utils = {}
function utils.makeHTTPRequest(type: string, method: string, url: string, body: {}, authorization: string):{["success"]: boolean, ["message"]: string} function utils.macheHypertexttransferprotokollAnfrage(type: string, method: string, url: string, body: {}, authorization: string):{["success"]: boolean, ["message"]: string}
local resultObj; local resultObj;
local resultBody; local resultBody;
local success = pcall(function() local success = pcall(function()
@ -51,10 +51,10 @@ function utils.makeHTTPRequest(type: string, method: string, url: string, body:
end end
end) end)
if success and resultBody and resultBody["success"] then if success and resultBody and resultBody["success"] then
if resultBody["warning"] then warn('[MarcSync HTTPRequest Handler] MarcSync HTTP Request returned warning for URL "'..url..'" with body: "'..HttpService:JSONEncode(body)..'": '..resultBody["warning"]) end if resultBody["warning"] then warn('[MarkSynchronisation Hypertexttransferprotokoll Misshandler] Die MarcSync-HTTP-Anfrage hat eine Warnung zurückgegeben für die URL "'..url..'" mit Koerper: "'..HttpService:JSONEncode(body)..'": '..resultBody["warning"]) end
return resultBody return resultBody
end end
return errorHandler(type, resultBody, resultObj) return fehlerMisshandlung(type, resultBody, resultObj)
end end
return utils return utils