Skip to content

Commit

Permalink
Show generic error instead of wrong error object.
Browse files Browse the repository at this point in the history
Closes #1147.
  • Loading branch information
imolorhe committed Jan 3, 2020
1 parent 2802c94 commit 27de737
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/app/effects/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ export class QueryEffects {
return new queryActions.SetQueryResultAction(result, response.windowId);
}),
catchError((error: any) => {
let output = 'Server Error';
let output = 'Server Error. Check that your server is up and running.' +
' You can check the console for more details on the network errors.';

debug.log(error);
requestStatusCode = error.status;
Expand Down
18 changes: 3 additions & 15 deletions src/app/services/gql/gql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,12 @@ export class GqlService {
if (err.error instanceof ErrorEvent) {
// A client-side or network error occurred. Handle it accordingly.
debug.error('An error occurred:', err.error.message);
} else if (err.error instanceof ProgressEvent) {
debug.error('Progress event error', err.error);
} else {
// The backend returned an unsuccessful response code.
// The response body may contain clues as to what went wrong,
debug.error(err.error);
debug.error(
`Backend returned code ${err.status}, ` +
`body was: ${err.error}`);
Expand All @@ -189,21 +192,6 @@ export class GqlService {
);
}

/**
* Send graphQL request and return the response
* @param query
* @param vars
*/
send(query: string, vars?: string, selectedOperation?: string, files?: fromVariables.FileVariable[], withCredentials?: boolean) {
return this._send({
query,
variables: vars,
selectedOperation,
files,
withCredentials,
}).pipe(map(res => res.body));
}

sendRequest(url: string, opts: SendRequestOptions) {
const files = opts.files && opts.files.length ? opts.files.filter(file => file && file.data instanceof File && file.name) : undefined;

Expand Down

0 comments on commit 27de737

Please sign in to comment.