File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,14 @@ public enum ErrorCode
205205 [ EditorBrowsable ( EditorBrowsableState . Never ) ]
206206 JobNotFound = 404002 ,
207207
208+ /// <summary>
209+ /// The operation failed because the device is offline or the direct method callback isn't registered.
210+ /// <para>
211+ /// For more information, see <see href="https://aka.ms/iothub404103">404103 Device not online</see>.
212+ /// </para>
213+ /// </summary>
214+ DeviceNotOnline = 404103 ,
215+
208216 /// <summary>
209217 /// The error is internal to IoT hub and is likely transient.
210218 /// <para>
Original file line number Diff line number Diff line change @@ -33,6 +33,25 @@ public async Task GetExceptionCodeAsync_ContentAndHeadersMatch_ValidErrorCode()
3333 Assert . AreEqual ( ErrorCode . DeviceNotFound , errorCode ) ;
3434 }
3535
36+ [ TestMethod ]
37+ public async Task GetExceptionCodeAsync_ContentAndHeadersMatch_ValidErrorCode_DeviceNotOnline ( )
38+ {
39+ // arrange
40+ var httpResponseMessage = new HttpResponseMessage ( System . Net . HttpStatusCode . BadRequest ) ;
41+ var exceptionResult = new IoTHubExceptionResult
42+ {
43+ Message = "{\" errorCode\" :404103}"
44+ } ;
45+ httpResponseMessage . Content = new StringContent ( JsonConvert . SerializeObject ( exceptionResult ) ) ;
46+ httpResponseMessage . Headers . Add ( CommonConstants . HttpErrorCodeName , "DeviceNotOnline" ) ;
47+
48+ // act
49+ ErrorCode errorCode = await ExceptionHandlingHelper . GetExceptionCodeAsync ( httpResponseMessage ) ;
50+
51+ // assert
52+ Assert . AreEqual ( ErrorCode . DeviceNotOnline , errorCode ) ;
53+ }
54+
3655 [ TestMethod ]
3756 public async Task GetExceptionCodeAsync_ContentAndHeadersMisMatch_InvalidErrorCode ( )
3857 {
You can’t perform that action at this time.
0 commit comments