Skip to content

Commit

Permalink
[UXE-5920] fix: parse correctly git hub installation callback post er…
Browse files Browse the repository at this point in the history
…rors (#2179)
  • Loading branch information
aloisio-m-bastian authored Feb 19, 2025
1 parent c2c4042 commit 0f9d646
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AxiosHttpClientAdapter, parseHttpResponse } from '../axios/AxiosHttpClientAdapter'
import { AxiosHttpClientAdapter } from '../axios/AxiosHttpClientAdapter'
import { makeVersionControlSystemBaseUrl } from './make-version-control-system-base-url'

import * as Errors from '@/services/axios/errors'
import { extractApiError } from '@/helpers/extract-api-error'
export const postCallbackUrlService = async (path, body) => {
let httpResponse = await AxiosHttpClientAdapter.request({
url: `${makeVersionControlSystemBaseUrl()}${path}`,
Expand All @@ -10,3 +11,19 @@ export const postCallbackUrlService = async (path, body) => {

return parseHttpResponse(httpResponse)
}

/**
* @param {Object} httpResponse - The HTTP response object.
* @param {Object} httpResponse.body - The response body.
* @returns {string} The formatted error message.
*/
const parseHttpResponse = (httpResponse) => {
switch (httpResponse.statusCode) {
case 200:
return { feedback: 'Git Hub Installation successfully completed' }
case 500:
throw new Errors.InternalServerError().message
default:
throw new Error(extractApiError(httpResponse)).message
}
}
14 changes: 12 additions & 2 deletions src/templates/template-engine-block/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,18 @@
const saveIntegration = async (integration) => {
isIntegrationsLoading.value = true
await props.postCallbackUrlService(callbackUrl.value, integration.data)
await listIntegrations()
try {
await props.postCallbackUrlService(callbackUrl.value, integration.data)
} catch (error) {
toast.add({
closable: true,
severity: 'error',
summary: 'error',
detail: error
})
} finally {
await listIntegrations()
}
}
const createSchemaObject = async () => {
Expand Down

0 comments on commit 0f9d646

Please sign in to comment.