To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

...
 
Commits (2)
# Changelog of IAMClient
## Version 1.2.3
Only minor changes to the error handling in `Invoke-IAMMethod`, it now reads the message returned from the webserver and returns it to the caller.
## Version 1.2.1
### Breaking Changes
- `Get-ETHUser` does not return two objects anymore on completion
### Bugfixes
- `Invoke-IAMMethod` _(not exported to public)_ Should now correctly return error messages when they are not in JSON format.
### Other remarks
## Version 1.1.0
### Breaking Changes
......
import-module "$PSScriptRoot\IAMClient.psd1"
import-module "iamclient"
function Main() {
......
......@@ -7,7 +7,7 @@
RootModule = 'IAMClient.psm1'
# Version number of this module.
ModuleVersion = '1.2.2'
ModuleVersion = '1.2.3'
# ID used to uniquely identify this module
GUID = '33ce3afe-9156-4f0e-bbc7-6d4fab3f2ad7'
......
......@@ -76,7 +76,23 @@ Function Invoke-IAMMethod {
# Only write to console if debug is enabled
if ($script:DebugMode) {
Write-RequestToConsole -Method $Method.ToString() -Headers $Headers -JsonBody $JsonBody
Write-ResponseToConsole -Response $Response
}
# if response is a string, is contains a json object
if ($null -ne $_.Exception.Response){
# read answer from stream
$responseStream = $_.Exception.Response.GetResponseStream()
$streamReader = new-object System.IO.StreamReader -ArgumentList $responseStream
$errResponse = $streamReader.ReadToEnd()
# clean up reader
$streamReader.Dispose()
$errObject = ConvertFrom-Json $errResponse
throw ($errObject.level + " -> " + $errObject.message)
} else {
throw $_.Exception.Message
}
try {
......@@ -84,11 +100,10 @@ Function Invoke-IAMMethod {
$errResponse = ConvertFrom-Json $_
}
catch {
Write-Error -Message $_.Exception.Message -Exception $_
Write-Error -Message $_.Exception.Message -Exception $_.Exception
return
}
Write-Error -Message ($errResponse.level + " -> " + $errResponse.message)
return
}
catch {
throw "API Request failed. Message: $_"
......