Skip to content

Commit

Permalink
fix: js-dataverse error types
Browse files Browse the repository at this point in the history
  • Loading branch information
MellyGray committed Oct 23, 2023
1 parent a8873b9 commit 22ca6af
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
getDataset,
getDatasetCitation,
getDatasetSummaryFieldNames,
WriteError,
Dataset as JSDataset,
getPrivateUrlDataset,
getPrivateUrlDatasetCitation
getPrivateUrlDatasetCitation,
ReadError
} from '@iqss/dataverse-client-javascript'
import { JSDatasetMapper } from '../mappers/JSDatasetMapper'

Expand All @@ -25,7 +25,7 @@ export class DatasetJSDataverseRepository implements DatasetRepository {
.then(([jsDataset, summaryFieldsNames, citation]: [JSDataset, string[], string]) =>
JSDatasetMapper.toDataset(jsDataset, citation, summaryFieldsNames)
)
.catch((error: WriteError) => {
.catch((error: ReadError) => {
if (!version) {
throw new Error(error.message)
}
Expand All @@ -42,7 +42,7 @@ export class DatasetJSDataverseRepository implements DatasetRepository {
.then(([jsDataset, summaryFieldsNames, citation]: [JSDataset, string[], string]) =>
JSDatasetMapper.toDataset(jsDataset, citation, summaryFieldsNames)
)
.catch((error: WriteError) => {
.catch((error: ReadError) => {
throw new Error(error.message)
})
}
Expand Down
10 changes: 5 additions & 5 deletions src/files/infrastructure/FileJSDataverseRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
getDatasetFilesTotalDownloadSize,
getFileDownloadCount,
getFileUserPermissions,
WriteError
ReadError
} from '@iqss/dataverse-client-javascript'
import { FileCriteria } from '../domain/models/FileCriteria'
import { DomainFileMapper } from './mappers/DomainFileMapper'
Expand Down Expand Up @@ -39,7 +39,7 @@ export class FileJSDataverseRepository implements FileRepository {
)
.then((jsFiles) => jsFiles.map((jsFile) => JSFileMapper.toFile(jsFile, datasetVersion)))
.then((files) => FileJSDataverseRepository.getAllWithDownloadCount(files))
.catch((error: WriteError) => {
.catch((error: ReadError) => {
throw new Error(error.message)
})
}
Expand Down Expand Up @@ -77,7 +77,7 @@ export class FileJSDataverseRepository implements FileRepository {
.then((jsFilesCountInfo) => {
return JSFileMapper.toFilesCountInfo(jsFilesCountInfo)
})
.catch((error: WriteError) => {
.catch((error: ReadError) => {
throw new Error(error.message)
})
}
Expand All @@ -88,7 +88,7 @@ export class FileJSDataverseRepository implements FileRepository {
): Promise<number> {
return getDatasetFilesTotalDownloadSize
.execute(datasetPersistentId, datasetVersion.toString(), FileDownloadSizeMode.ARCHIVAL)
.catch((error: WriteError) => {
.catch((error: ReadError) => {
throw new Error(error.message)
})
}
Expand All @@ -99,7 +99,7 @@ export class FileJSDataverseRepository implements FileRepository {
.then((jsFileUserPermissions) =>
JSFileMapper.toFileUserPermissions(id, jsFileUserPermissions)
)
.catch((error: WriteError) => {
.catch((error: ReadError) => {
throw new Error(error.message)
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getDataverseVersion, WriteError } from '@iqss/dataverse-client-javascript'
import { getDataverseVersion, ReadError } from '@iqss/dataverse-client-javascript'
import { DataverseInfoRepository } from '../../domain/repositories/DataverseInfoRepository'
import { DataverseVersion } from '../../domain/models/DataverseVersion'

Expand All @@ -22,7 +22,7 @@ export class DataverseInfoJSDataverseRepository implements DataverseInfoReposito
.then((jsDataverseDataverseVersion: JSDataverseDataverseVersion) =>
DataverseInfoJSDataverseRepository.formatVersion(jsDataverseDataverseVersion)
)
.catch((error: WriteError) => {
.catch((error: ReadError) => {
throw new Error(error.message)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { MetadataBlockInfoRepository } from '../../domain/repositories/MetadataB
import { MetadataBlockInfo } from '../../domain/models/MetadataBlockInfo'
import {
getMetadataBlockByName,
MetadataBlock as JSMetadataBlockInfo
MetadataBlock as JSMetadataBlockInfo,
ReadError
} from '@iqss/dataverse-client-javascript'
import { JSMetadataBlockInfoMapper } from '../mappers/JSMetadataBlockInfoMapper'

Expand All @@ -13,5 +14,8 @@ export class MetadataBlockInfoJSDataverseRepository implements MetadataBlockInfo
.then((jsMetadataBlockInfo: JSMetadataBlockInfo) =>
JSMetadataBlockInfoMapper.toMetadataBlockInfo(jsMetadataBlockInfo)
)
.catch((error: ReadError) => {
throw new Error(error.message)
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {
AuthenticatedUser,
getCurrentAuthenticatedUser
} from '@iqss/dataverse-client-javascript/dist/users'
import { ReadError } from '@iqss/dataverse-client-javascript/dist/core'
import { logout, WriteError } from '@iqss/dataverse-client-javascript'
import { logout, ReadError, WriteError } from '@iqss/dataverse-client-javascript'
import { UserRepository } from '../../domain/repositories/UserRepository'

export class UserJSDataverseRepository implements UserRepository {
Expand Down

0 comments on commit 22ca6af

Please sign in to comment.