Skip to content

Commit eed6c90

Browse files
authored
Remove unused method and improve error logging
1 parent 517d393 commit eed6c90

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

Yubico.YubiKey/src/Yubico/YubiKey/Pipelines/CommandChainingTransform.cs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 Yubico AB
1+
// Copyright 2021 Yubico AB
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License").
44
// You may not use this file except in compliance with the License.
@@ -67,12 +67,11 @@ private ResponseApdu SendChainedApdu(CommandApdu command, Type commandType, Type
6767
while (!sourceData.IsEmpty)
6868
{
6969
responseApdu = SendPartial(command, commandType, responseType, ref sourceData);
70-
if (responseApdu.SW == SWConstants.Success)
70+
if (responseApdu.SW != SWConstants.Success)
7171
{
72-
continue;
72+
_log.LogWarning("Received error response from YubiKey. (SW: 0x{StatusWord})", responseApdu.SW.ToString("X4", CultureInfo.CurrentCulture));
73+
return responseApdu;
7374
}
74-
75-
return FailedResponse(responseApdu);
7675
}
7776

7877
return responseApdu!;
@@ -102,22 +101,5 @@ private ResponseApdu SendPartial(
102101
var responseApdu = _pipeline.Invoke(partialApdu, commandType, responseType);
103102
return responseApdu;
104103
}
105-
106-
private ResponseApdu FailedResponse(ResponseApdu responseApdu)
107-
{
108-
var currentCulture = CultureInfo.CurrentCulture;
109-
string errorMessage = responseApdu.SW switch
110-
{
111-
SWConstants.WrongLength => string.Format(
112-
currentCulture, "Sent data exceeds max allowed length by YubiKey. (SW: 0x{0})",
113-
responseApdu.SW.ToString("X4", currentCulture)),
114-
_ => string.Format(
115-
currentCulture, "Received error response from YubiKey. (SW: 0x{0})",
116-
responseApdu.SW.ToString("X4", currentCulture))
117-
};
118-
119-
_log.LogWarning(errorMessage);
120-
return responseApdu;
121-
}
122104
}
123105
}

0 commit comments

Comments
 (0)