Skip to content

Commit

Permalink
feat: add error type used by device service data transformation
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Hung <chris@iotechsys.com>
  • Loading branch information
Chris Hung committed Mar 5, 2021
1 parent 6e37081 commit 076855e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions errors/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2020 IOTech Ltd
// Copyright (C) 2020-2021 IOTech Ltd
//
// SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -34,6 +34,8 @@ const (
KindRangeNotSatisfiable ErrKind = "RangeNotSatisfiable"
KindClientError ErrKind = "ClientError"
KindIOError ErrKind = "IOError"
KindOverflowError ErrKind = "OverflowError"
KindNaNError ErrKind = "NaNError"
)

// Error codes are not defined in HTTP status codes
Expand Down Expand Up @@ -186,7 +188,7 @@ func getCallerInformation() string {
// codeMapping determines the correct HTTP response code for the given error kind.
func codeMapping(kind ErrKind) int {
switch kind {
case KindUnknown, KindDatabaseError, KindServerError:
case KindUnknown, KindDatabaseError, KindServerError, KindOverflowError, KindNaNError:
return http.StatusInternalServerError
case KindCommunicationError:
return http.StatusBadGateway
Expand Down

0 comments on commit 076855e

Please sign in to comment.