| 28 | }; |
| 29 | |
| 30 | const detectErrorMessage = (response: any, authenticated: boolean) => { |
| 31 | if (response?.status === 401 && response?.data?.message?.includes?.('Unauthorized')) { |
| 32 | return errorMessages.badCredentials[authenticated ? 'authenticated' : 'anonymous']; |
| 33 | } |
| 34 | if (response?.status === 404) { |
| 35 | return errorMessages.repoNotFound[authenticated ? 'authenticated' : 'anonymous']; |
| 36 | } |
| 37 | if (response?.status === 403) { |
| 38 | return errorMessages.noPermission[authenticated ? 'authenticated' : 'anonymous']; |
| 39 | } |
| 40 | return response?.data?.message || response?.data?.error || ''; |
| 41 | }; |
| 42 | |
| 43 | const PREFER_SOURCEGRAPH_API = 'PREFER_SOURCEGRAPH_API'; |
| 44 | |