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

Add error handling to invalid args #36

Merged
merged 1 commit into from
May 26, 2022
Merged

Conversation

bioerrorlog
Copy link
Collaborator

@bioerrorlog bioerrorlog commented May 25, 2022

概要・目的

Fixes #35

変更内容

やったこと

  • artGeneratorとuploadImagesの引数が指定されていない場合or数値以外が渡された場合のエラーハンドリングを追加

やらないこと

影響範囲

  • artGenerator
  • uploadImages

動作確認

下記コマンド実行時に想定のエラーが返されることを確認。

npm run generate:images -start=10
npm run generate:images -end=11
npm run generate:images
npm run generate:images -start=aaa -end=bbb
npm run upload:images -start=10
npm run upload:images -end=11
npm run upload:images
npm run upload:images -start=aaa -end=bbb

補足

upload:images実行時に下記エラーが出るのは私だけですかね..?
(↑の動作確認は該当部分コメントアウトして行いました)

TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///home/nor-code/codes/generative-art-nft/.dfx/local/canister_ids.json" needs an import assertion of type "json"
    at new NodeError (node:internal/errors:372:5)
    at validateAssertions (node:internal/modules/esm/assert:82:15)
    at defaultLoad (node:internal/modules/esm/load:24:3)
    at /home/nor-code/codes/generative-art-nft/node_modules/ts-node/src/esm.ts:255:45
    at async addShortCircuitFlag (/home/nor-code/codes/generative-art-nft/node_modules/ts-node/src/esm.ts:409:15)
    at async ESMLoader.load (node:internal/modules/esm/loader:407:20)
    at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:11) {
  code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}

追記
使用しているnodeのversionの違いによりそうですね..

Import assertions were introduced in node v17.1.0 according to this, but became required after v17.5.0 (related to this change:github.com/nodejs/node/pull/40785). Import assertions address a security concern (v8.dev/features/import-assertions) about trusting cross-origin imports.

https://stackoverflow.com/questions/70106880/err-import-assertion-type-missing-for-import-of-json-file

※自分は↓でした。

$ node --version
v17.7.1

@bioerrorlog bioerrorlog self-assigned this May 25, 2022
Copy link
Collaborator

@hoosan hoosan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMです!

Node.js 自分はv16でした(GitHub Actionsに合わせてました)。
Node.jsは偶数番号が安定版でして、v18が4月にリリースされてますので、上げるならv18かなと思っています🙏

@hoosan hoosan merged commit 80f411e into main May 26, 2022
@bioerrorlog bioerrorlog deleted the feature/add-args-handling branch May 26, 2022 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

引数不足の場合のエラーハンドリング
2 participants