Skip to content

Commit

Permalink
refactor: error handling and File import
Browse files Browse the repository at this point in the history
Refs: #25
  • Loading branch information
bucurdavid committed Sep 20, 2023
1 parent 7427c54 commit a6339cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/mint-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NFTStorage } from 'nft.storage';
import { NFTStorage, File } from 'nft.storage';

export async function dataNFTDataStreamAdvertise(
dataNFTStreamUrl: string,
Expand Down
5 changes: 5 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ export class ErrNetworkConfig extends Error {
}
}

export class ErrArgumentNotSet extends Error {
public constructor(argument: string, message?: string) {
super(`Argument "${argument}" is not set. ${message}`);
}
}
export class ErrInvalidArgument extends Error {
public constructor(message: string) {
super(`Invalid argument: ${message}`);
Expand Down
8 changes: 3 additions & 5 deletions src/nft-minter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
storeToIpfs
} from './common/mint-utils';
import { ContractConfiguration } from './interfaces';
import { ErrArgumentNotSet } from './errors';

export class NftMinter extends Minter {
/**
Expand Down Expand Up @@ -234,13 +235,10 @@ export class NftMinter extends Minter {

if (!imageUrl) {
if (!nftStorageToken) {
throw new Error(
throw new ErrArgumentNotSet(
'nftStorageToken',
'NFT Storage token is required when not using custom image and traits'
);
// throw new ErrArgumentNotSet(
// 'nftStorageToken',
// 'NFT Storage token is required when not using custom image and traits'
// );
}
const { image, traits } = await createFileFromUrl(
`${this.imageServiceUrl}/v1/generateNFTArt?hash=${dataNftHash}`,
Expand Down

0 comments on commit a6339cb

Please sign in to comment.