Render writes a Graph Error object to the response writer
(w http.ResponseWriter, r *http.Request)
| 130 | |
| 131 | // Render writes a Graph Error object to the response writer |
| 132 | func (e Error) Render(w http.ResponseWriter, r *http.Request) { |
| 133 | var status int |
| 134 | switch e.errorCode { |
| 135 | case AccessDenied: |
| 136 | status = http.StatusForbidden |
| 137 | case NotSupported: |
| 138 | status = http.StatusNotImplemented |
| 139 | case InvalidRange: |
| 140 | status = http.StatusRequestedRangeNotSatisfiable |
| 141 | case InvalidRequest: |
| 142 | status = http.StatusBadRequest |
| 143 | case ItemNotFound: |
| 144 | status = http.StatusNotFound |
| 145 | case NameAlreadyExists: |
| 146 | status = http.StatusConflict |
| 147 | case NotAllowed: |
| 148 | status = http.StatusMethodNotAllowed |
| 149 | case ItemIsLocked: |
| 150 | status = http.StatusLocked |
| 151 | case PreconditionFailed: |
| 152 | status = http.StatusPreconditionFailed |
| 153 | default: |
| 154 | status = http.StatusInternalServerError |
| 155 | } |
| 156 | e.errorCode.Render(w, r, status, e.msg) |
| 157 | } |
| 158 | |
| 159 | // String returns the string corresponding to the ErrorCode |
| 160 | func (e ErrorCode) String() string { |
no outgoing calls
no test coverage detected