-
Notifications
You must be signed in to change notification settings - Fork 128
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
Display error/warning for too large input #72 #168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ongspxm,
thanks for your first contribution to this project! 🎉 👍
I hope you'll like this project and enjoy hacking on it… 😃
So the change itself looks generally good.
However, I am not sure whether it solves #72 completely.
Did you test both the SVG and Canvas version? (Which version does throw this error? Likely not both…)
Also notice you may need to move the code to the specific files for the libraries then. 😄
may need to alter the kjua.min file |
ready for second round of review, and the kjua thing is kinda hackish, my change is at the end of the min file. search for the only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and the kjua thing is kinda hackish
As you noticed, it very obviously is… 😆
And I really don't want to maintain a forked version of kjua or so…
And also, I don't really want to review minified source code. No really…
What I see is this change:
-catch(r){if(!n.test(r.message))throw r}return null}
+catch(r){if(!(a<40&&n.test(r.message)))throw r}return null}
So why only for < 40 chars etc.??
I do not understand that change at all…
So here is what you can do:
- get your change accepted as a PR in the upstream project: https://github.com/lrsjng/kjua/pulls (obviously, you need to explain there why you need this change etc.)
- work around it…?
Is not there some other functionality/difference that you can see from the outside if the length is too long? (I mean the function you changed should returnnull
in this case?)
In any case, please revert the change to the minified kjua lib…
Also in our code base: Please don't throw strings around. When you need to catch them from dependencies (libs) you have obviously no other chance, but here I would recommend custom ES6 error types. They are used multiple times in this project and e.g. the Mastodon addon, so you can get some inspiration from there.
When you use them you can handle the specific "error catching & conversion" in the respective QrLib
files and handle the actual error (i.e. showing user error etc.) in UserInterface
or so…
Also small thing: Do not forget to document when a function throws something.
Haha, there is 40 versions of qrcode, each accepting more characters than the last. What the lib returns is a canvas or image. And when it runs out of the 40 versions or qrcode, it just returns a blank canvas or image. There isnt a way of determining if its good, because from the outside, the inage is the same. I could try making a pull request to the library repo. opened: lrsjng/kjua#12 |
Co-Authored-By: ongspxm <ongspxm@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, then I'll let upstream some time for merging your change. As that, I mark it as blocked and hope upstream will do something.
However, your PR itself still needs some changes as commented before. (e.g. usage of error classes)
BTW, marking this as blocked by lrsjng/kjua#12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only some minor other changes...
Got unblocked as lrsjng/kjua#12 has been merged 😄 As upstream also updated/changed a little more, can you update the lib to the new version and test whether it works as expected. (Also as for this change here?) |
And extra thing: Maybe we can mention somewhere in the source code (or file name?), which (in this case) kjua version we are using? |
Co-Authored-By: ongspxm <ongspxm@gmail.com>
It's version 0.2.0, not 2.0... 😃 |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-Authored-By: ongspxm <ongspxm@gmail.com>
@rugk thanks for the fast review, ready again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, considering clicking "resolve conversation" on an issue, you've resolved. 😄 (Then you should also notice, if you forget a review comment. 😉)
Co-Authored-By: ongspxm <ongspxm@gmail.com>
Co-Authored-By: ongspxm <ongspxm@gmail.com>
Co-Authored-By: ongspxm <ongspxm@gmail.com>
introduced in rugk#168
close #72