Skip to content

Commit 95f8c11

Browse files
Handle unexpected return types slightly more gracefully
1 parent 3d86cf9 commit 95f8c11

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/main/java/engineer/nightowl/sonos/api/resource/BaseResource.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,18 @@ private SonosType getTypeFromHeader(final CloseableHttpResponse response)
142142
final Header header = response.getFirstHeader(SONOS_TYPE_HEADER);
143143
if (header != null && !SonosUtilityHelper.isEmpty(header.getValue()))
144144
{
145-
if (!"none".equalsIgnoreCase(header.getValue()))
145+
final String headerValue = header.getValue();
146+
if (!"none".equalsIgnoreCase(headerValue))
146147
{
147-
return SonosType.valueOf(header.getValue());
148+
try
149+
{
150+
return SonosType.valueOf(headerValue);
151+
}
152+
catch (final IllegalArgumentException iae)
153+
{
154+
final String msg = String.format("Unexpected return type [%s] - please raise a bug", headerValue);
155+
throw new SonosApiClientException(msg, iae);
156+
}
148157
}
149158
}
150159
}

0 commit comments

Comments
 (0)