Skip to content

Commit

Permalink
revert unused axios error changes
Browse files Browse the repository at this point in the history
  • Loading branch information
raosan committed Jan 17, 2025
1 parent 8685067 commit 105ca76
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
21 changes: 18 additions & 3 deletions packages/notification/channel/instatus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import type { AxiosRequestConfig } from 'axios'
import http from 'http'
import https from 'https'
import Joi from 'joi'
import { getErrorMessage } from '../../utils/catch-error-handler.js'
import {
findIncident,
insertIncident as insertIncidentToDatabase,
Expand Down Expand Up @@ -140,7 +139,15 @@ async function createIncident(

await insertIncidentToDatabase({ incidentID, probeID, status, url })
} catch (error: unknown) {
throw new Error(getErrorMessage(error))
const axiosError =
error instanceof axios.AxiosError ? error : new axios.AxiosError()

Check warning on line 143 in packages/notification/channel/instatus/index.ts

View workflow job for this annotation

GitHub Actions / lint

Caution: `axios` also has a named export `AxiosError`. Check if you meant to write `import {AxiosError} from 'axios'` instead

Check warning on line 143 in packages/notification/channel/instatus/index.ts

View workflow job for this annotation

GitHub Actions / lint

Caution: `axios` also has a named export `AxiosError`. Check if you meant to write `import {AxiosError} from 'axios'` instead
throw new Error(
`${axiosError?.message}${
axiosError?.response?.data
? `. ${axiosError?.response?.data?.message}`
: ''
}`
)
}
}

Expand Down Expand Up @@ -185,7 +192,15 @@ async function updateIncident(
getAxiosConfig(apiKey)
)
} catch (error: unknown) {
throw new Error(getErrorMessage(error))
const axiosError =
error instanceof axios.AxiosError ? error : new axios.AxiosError()

Check warning on line 196 in packages/notification/channel/instatus/index.ts

View workflow job for this annotation

GitHub Actions / lint

Caution: `axios` also has a named export `AxiosError`. Check if you meant to write `import {AxiosError} from 'axios'` instead

Check warning on line 196 in packages/notification/channel/instatus/index.ts

View workflow job for this annotation

GitHub Actions / lint

Caution: `axios` also has a named export `AxiosError`. Check if you meant to write `import {AxiosError} from 'axios'` instead
throw new Error(
`${axiosError.message}${
axiosError?.response?.data
? `. ${axiosError?.response?.data?.message}`
: ''
}`
)
}

await updateIncidentToDatabase({ incidentID, status })
Expand Down
21 changes: 18 additions & 3 deletions src/plugins/visualization/atlassian-status-page/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import http from 'http'
import https from 'https'
import Joi from 'joi'

import { getErrorMessage } from '../../../utils/catch-error-handler.js'
import {
findIncident,
insertIncident as insertIncidentToDatabase,
Expand Down Expand Up @@ -136,7 +135,15 @@ export class AtlassianStatusPageAPI {

return incidentID
} catch (error: unknown) {
throw new Error(getErrorMessage(error))
const axiosError =
error instanceof axios.AxiosError ? error : new axios.AxiosError()
throw new Error(
`${axiosError?.message}${
axiosError?.response?.data
? `. ${axiosError?.response?.data?.message}`
: ''
}`
)
}
}

Expand Down Expand Up @@ -168,7 +175,15 @@ export class AtlassianStatusPageAPI {
this.axiosConfig
)
} catch (error: unknown) {
throw new Error(getErrorMessage(error))
const axiosError =
error instanceof axios.AxiosError ? error : new axios.AxiosError()
throw new Error(
`${axiosError?.message}${
axiosError?.response?.data
? `. ${axiosError?.response?.data?.message}`
: ''
}`
)
}

await updateIncidentToDatabase({ incidentID, status })
Expand Down

0 comments on commit 105ca76

Please sign in to comment.