github.com/rohankumardubey/aresdb@v0.0.2-0.20190517170215-e54e3ca06b9c/api/error.go (about) 1 // Copyright (c) 2017-2018 Uber Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package api 16 17 import ( 18 "net/http" 19 20 "github.com/uber/aresdb/utils" 21 ) 22 23 var ( 24 // ErrMsgFailedToUnmarshalRequest represents error message for unmarshal error. 25 ErrMsgFailedToUnmarshalRequest = "Bad request: failed to unmarshal request body" 26 // ErrMsgMissingParameter represents error message for missing params error. 27 ErrMsgMissingParameter = "Bad request: missing/invalid parameter" 28 // ErrMsgFailedToReadRequestBody represents error message for unable to read request body error. 29 ErrMsgFailedToReadRequestBody = "Bad request: failed to read request body" 30 // ErrMsgNonExistentTable represents error message for table does not exist 31 ErrMsgNonExistentTable = "Bad request: table does not exist" 32 // ErrMsgNonExistentColumn represents error message for column does not exist 33 ErrMsgNonExistentColumn = "Bad request: column does not exist" 34 // ErrMsgDeletedColumn represents error message for column is already deleted 35 ErrMsgDeletedColumn = "Bad request: column is already deleted" 36 // ErrMsgNotImplemented represents error message for method not implemented. 37 ErrMsgNotImplemented = "Not implemented" 38 // ErrMsgFailedToJSONMarshalResponseBody respresents error message for failure to marshal 39 // response body into json. 40 ErrMsgFailedToJSONMarshalResponseBody = "Failed to marshal the response body into json" 41 // ErrMissingParameter represents api error for missing parameter 42 ErrMissingParameter = utils.APIError{ 43 Code: http.StatusBadRequest, 44 Message: ErrMsgMissingParameter, 45 } 46 // ErrNotImplemented represents api error for method not implemented. 47 ErrNotImplemented = utils.APIError{ 48 Code: http.StatusNotImplemented, 49 Message: ErrMsgNotImplemented, 50 } 51 // ErrTableDoesNotExist represents api error for table does not exist. 52 ErrTableDoesNotExist = utils.APIError{ 53 Code: http.StatusBadRequest, 54 Message: ErrMsgNonExistentTable, 55 } 56 // ErrColumnDoesNotExist represents api error for column does not exist. 57 ErrColumnDoesNotExist = utils.APIError{ 58 Code: http.StatusBadRequest, 59 Message: ErrMsgNonExistentColumn, 60 } 61 // ErrColumnDeleted represents api error for column is already deleted. 62 ErrColumnDeleted = utils.APIError{ 63 Code: http.StatusBadRequest, 64 Message: ErrMsgDeletedColumn, 65 } 66 // ErrBatchDoesNotExist represents api error for batch does not exist. 67 ErrBatchDoesNotExist = utils.APIError{ 68 Code: http.StatusBadRequest, 69 Message: "Bad request: batch does not exist", 70 } 71 // ErrFailedToJSONMarshalResponseBody represents the api error for failure to marshal 72 // response body into json. 73 ErrFailedToJSONMarshalResponseBody = utils.APIError{ 74 Code: http.StatusInternalServerError, 75 Message: ErrMsgFailedToJSONMarshalResponseBody, 76 } 77 )