Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add more descriptive errors on task/workflow run failure #370

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion src/models/AdminEntity/transformRequestError.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
import { AxiosError } from 'axios';
import { NotAuthorizedError, NotFoundError } from 'errors/fetchErrors';
import { Admin } from 'flyteidl';
import { decodeProtoResponse } from './utils';

// to enrich the error message by adding the response
function decodeErrorResponseMessage(error: AxiosError) {
try {
// probablly using a wrong decode type.. is there a decode type for the error message?
const decodedErrorResponseMessage = decodeProtoResponse(
error.response?.data,
Admin.RawOutputDataConfig,
);
if (decodedErrorResponseMessage && decodedErrorResponseMessage.outputLocationPrefix) {
const errorStatusMessage = error?.message;
const errorResponseMessage = decodedErrorResponseMessage.outputLocationPrefix;

return new Error(`${errorStatusMessage} ${errorResponseMessage}`);
}
} catch (err) {
// do nothing
}
return error;
}

/** Detects special cases for errors returned from Axios and lets others pass through. */
export function transformRequestError(err: unknown, path: string) {
const error = err as AxiosError;

if (!error.response) {
return error;
}
Expand All @@ -17,5 +40,5 @@ export function transformRequestError(err: unknown, path: string) {
return new NotAuthorizedError();
}

return error;
return decodeErrorResponseMessage(error);
}