mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-11-20 23:03:40 +00:00
Merge pull request #213 from Jigsaw-Code/trevj-api-logging
add a little more detail to api request failures
This commit is contained in:
commit
bdcd63c8f8
1 changed files with 10 additions and 7 deletions
|
|
@ -19,7 +19,9 @@ import {SentryErrorReporter} from './error_reporter';
|
|||
interface MetricsEnabled {
|
||||
metricsEnabled: boolean;
|
||||
}
|
||||
export interface ServerName { name: string; }
|
||||
export interface ServerName {
|
||||
name: string;
|
||||
}
|
||||
export interface ServerConfig {
|
||||
name: string;
|
||||
metricsEnabled: boolean;
|
||||
|
|
@ -171,21 +173,22 @@ export class ShadowboxServer implements server.Server {
|
|||
apiAddress += '/';
|
||||
}
|
||||
const url = apiAddress + path;
|
||||
console.log(`Fetching url ${url}...`);
|
||||
return fetch(url, options)
|
||||
.then(
|
||||
(response) => {
|
||||
console.log('Fetch result:', url, response.ok);
|
||||
if (!response.ok) {
|
||||
const msg = 'Failed to fetch API request results';
|
||||
const msg = `API request to ${path} failed with status ${response.status}, type ${
|
||||
response.type}`;
|
||||
console.error(msg);
|
||||
SentryErrorReporter.logError(msg);
|
||||
throw new Error(msg);
|
||||
}
|
||||
console.debug(`API request to ${path} succeeded`);
|
||||
return response.text();
|
||||
},
|
||||
(error: Error) => {
|
||||
const msg = 'Failed to fetch url';
|
||||
console.error(msg, url, error);
|
||||
(error) => {
|
||||
const msg = `API request to ${path} failed due to network error`;
|
||||
console.error(msg, error);
|
||||
SentryErrorReporter.logError(msg);
|
||||
throw error;
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue