Skip to content

Commit

Permalink
Merge pull request #17969 from jmchilton/axios_to_fetcher_job_errors
Browse files Browse the repository at this point in the history
Use typed API client for reporting job errors.
  • Loading branch information
martenson authored Apr 11, 2024
2 parents 58490e5 + d0e81db commit 8568c9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions client/src/api/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export const jobLockUpdate = fetcher.path("/api/job_lock").method("put").create(
export const fetchJobDestinationParams = fetcher.path("/api/jobs/{job_id}/destination_params").method("get").create();

export const jobsFetcher = fetcher.path("/api/jobs").method("get").create();

export const jobsReportError = fetcher.path("/api/jobs/{job_id}/error").method("post").create();
15 changes: 7 additions & 8 deletions client/src/components/DatasetInformation/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ import axios from "axios";
import { getAppRoot } from "onload/loadConfig";
import { rethrowSimple } from "utils/simple-error";

import { jobsReportError } from "@/api/jobs";

export async function sendErrorReport(dataset, message, email) {
const payload = {
const jobId = dataset.creating_job;
const request = {
job_id: jobId,
dataset_id: dataset.id,
message,
email,
};
const url = `${getAppRoot()}api/jobs/${dataset.creating_job}/error`;
try {
const { data } = await axios.post(url, payload);
return data.messages;
} catch (e) {
rethrowSimple(e);
}
const { data } = await jobsReportError(request);
return data.messages;
}

export async function setAttributes(datasetId, settings, operation) {
Expand Down

0 comments on commit 8568c9e

Please sign in to comment.