(error: OneNoteApi.RequestError)
| 39 | } |
| 40 | |
| 41 | export function getApiResponseCode(error: OneNoteApi.RequestError): string { |
| 42 | if (!error || !error.response) { |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | let responseAsJson: any; |
| 47 | try { |
| 48 | responseAsJson = JSON.parse(error.response); |
| 49 | } catch (e) { |
| 50 | Clipper.logger.logJsonParseUnexpected(error.response); |
| 51 | } |
| 52 | |
| 53 | let apiResponseCode: string; |
| 54 | if (responseAsJson && responseAsJson.error && responseAsJson.error.code) { |
| 55 | apiResponseCode = responseAsJson.error.code; |
| 56 | } |
| 57 | |
| 58 | return apiResponseCode ? apiResponseCode : undefined; |
| 59 | } |
| 60 | |
| 61 | export function getLocalizedErrorMessage(apiResponseCode: string): string { |
| 62 | let responseCodeInfo = getResponseCodeInformation(apiResponseCode); |
no outgoing calls
no test coverage detected