A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.
TypeScript amazon-primeelectronepic-games-launcherepic-games-storeepic-storegaminggoggog-galaxyheroic-games-launcherlinuxplay-gamesprotonsteamwine
import { isAxiosError } from 'axios'
export function httpStatus(error: unknown): number | undefined {
return isAxiosError(error) ? error.response?.status : undefined
}
/**
* One line description of an error, for logs that are expected to happen
* (network blocks, rate limits, offline stores).
*
* Passing the raw error to the logger prints a full stack trace, which is
* useful for a bug but floods the log for a known HTTP failure.
*/
export function summarizeError(error: unknown): string {
if (!error) return 'unknown error'
if (isAxiosError(error)) {
const status = error.response?.status
const url = error.config?.url
const suffix = url ? ` (${url})` : ''
if (status) return `HTTP ${status}${suffix}`
return `${error.code ?? 'request failed'}${suffix}`
}
if (error instanceof Error) return error.message
return String(error)
}