-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #172 from metrico/dev
Weekly update
- Loading branch information
Showing
169 changed files
with
3,506 additions
and
2,488 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 69 additions & 69 deletions
138
src/actions/errorHandler.js → src/actions/errorHandler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
export const errorHandler = (error) => { | ||
|
||
const LABELS_URL = "/loki/api/v1/label"; | ||
const QUERY_URL = "/loki/api/v1/query_range"; | ||
|
||
const { request, response } = error; | ||
const url = error?.response?.request?.responseURL | ||
|
||
|
||
let type = () => { | ||
switch(url) { | ||
case url?.includes(LABELS_URL): | ||
return 'label'; | ||
case url?.includes(QUERY_URL): | ||
return 'query' | ||
default: return 'label' | ||
} | ||
} | ||
|
||
if (response?.statusText) { | ||
const status = response?.status; | ||
|
||
return { | ||
message: "API " + response.statusText + ", Please adjust API URL", | ||
status, | ||
type: type() | ||
}; | ||
} else if (url && !url.includes(window.location.protocol)) { | ||
|
||
return { | ||
message: "Mixed Content Error, your View should be over same protocol as your API", | ||
status: 500, | ||
type : type() | ||
}; | ||
} else if (request) { | ||
if (error.stack.includes('Network Error')) { | ||
return { | ||
message: "Invalid API URL, please adjust API URL", | ||
status: 500, | ||
type: type() | ||
} | ||
} | ||
return { | ||
message: "server time out", | ||
status: response?.status, | ||
type: type() | ||
}; | ||
} else if (error?.stack?.includes("Invalid URL")) { | ||
return { | ||
message: "Invalid API URL, please adjust API URL", | ||
stauts: response?.status, | ||
type: type() | ||
}; | ||
} else if (error?.response?.status === 404) { | ||
return { | ||
message: "Invalid API URL, please adjust API URL", | ||
status: response?.status, | ||
type: type() | ||
}; | ||
} else { | ||
if (type === 'labels') return; | ||
|
||
return { | ||
message: "something went wrong with request", | ||
status: response?.status, | ||
type: type() | ||
}; | ||
} | ||
}; | ||
export const errorHandler = (error: any) => { | ||
|
||
const LABELS_URL = "/loki/api/v1/label"; | ||
const QUERY_URL = "/loki/api/v1/query_range"; | ||
|
||
const { request, response } = error; | ||
const url = error?.response?.request?.responseURL | ||
|
||
|
||
let type = () => { | ||
switch(url) { | ||
case url?.includes(LABELS_URL): | ||
return 'label'; | ||
case url?.includes(QUERY_URL): | ||
return 'query' | ||
default: return 'label' | ||
} | ||
} | ||
|
||
if (response?.statusText) { | ||
const status = response?.status; | ||
|
||
return { | ||
message: "API " + response.statusText + ", Please adjust API URL", | ||
status, | ||
type: type() | ||
}; | ||
} else if (url && !url.includes(window.location.protocol)) { | ||
|
||
return { | ||
message: "Mixed Content Error, your View should be over same protocol as your API", | ||
status: 500, | ||
type : type() | ||
}; | ||
} else if (request) { | ||
if (error.stack.includes('Network Error')) { | ||
return { | ||
message: "Invalid API URL, please adjust API URL", | ||
status: 500, | ||
type: type() | ||
} | ||
} | ||
return { | ||
message: "server time out", | ||
status: response?.status, | ||
type: type() | ||
}; | ||
} else if (error?.stack?.includes("Invalid URL")) { | ||
return { | ||
message: "Invalid API URL, please adjust API URL", | ||
stauts: response?.status, | ||
type: type() | ||
}; | ||
} else if (error?.response?.status === 404) { | ||
return { | ||
message: "Invalid API URL, please adjust API URL", | ||
status: response?.status, | ||
type: type() | ||
}; | ||
} else { | ||
// if (type === 'labels') return; | ||
|
||
return { | ||
message: "something went wrong with request", | ||
status: response?.status, | ||
type: type() | ||
}; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.