aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/api
diff options
context:
space:
mode:
authorWouter Admiraal <wouter.admiraal@sonarsource.com>2021-04-19 14:30:09 +0200
committersonartech <sonartech@sonarsource.com>2021-04-22 20:03:34 +0000
commit17453c73bc0eeab032ca66619347dee91bfec4bb (patch)
treef22c6cc82a5ddeb2c305330d485c3a175ff0342a /server/sonar-web/src/main/js/api
parentc36b12d2160dd7c57bb7374345a02ebb91ae31e9 (diff)
downloadsonarqube-17453c73bc0eeab032ca66619347dee91bfec4bb.tar.gz
sonarqube-17453c73bc0eeab032ca66619347dee91bfec4bb.zip
SONAR-13737 Show descriptive error messages for GitLab PAT validation
Diffstat (limited to 'server/sonar-web/src/main/js/api')
-rw-r--r--server/sonar-web/src/main/js/api/alm-integrations.ts16
1 files changed, 9 insertions, 7 deletions
diff --git a/server/sonar-web/src/main/js/api/alm-integrations.ts b/server/sonar-web/src/main/js/api/alm-integrations.ts
index cc287712341..7bdd9e14622 100644
--- a/server/sonar-web/src/main/js/api/alm-integrations.ts
+++ b/server/sonar-web/src/main/js/api/alm-integrations.ts
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { get, getJSON, post, postJSON } from 'sonar-ui-common/helpers/request';
+import { get, getJSON, parseError, post, postJSON } from 'sonar-ui-common/helpers/request';
import throwGlobalError from '../app/utils/throwGlobalError';
import {
AzureProject,
@@ -34,15 +34,17 @@ export function setAlmPersonalAccessToken(almSetting: string, pat: string): Prom
return post('/api/alm_integrations/set_pat', { almSetting, pat }).catch(throwGlobalError);
}
-export function checkPersonalAccessTokenIsValid(almSetting: string): Promise<boolean> {
+export function checkPersonalAccessTokenIsValid(
+ almSetting: string
+): Promise<{ status: boolean; error?: string }> {
return get('/api/alm_integrations/check_pat', { almSetting })
- .then(() => true)
- .catch((response: Response) => {
+ .then(() => ({ status: true }))
+ .catch(async (response: Response) => {
if (response.status === 400) {
- return false;
- } else {
- return throwGlobalError(response);
+ const error = await parseError(response);
+ return { status: false, error };
}
+ return throwGlobalError(response);
});
}