Comments (5)
I'm wondering if the sanest thing here would be to plan for an error object that is thrown with validation errors/warnings. Then we could catch them and display them at a single point in our app. Plus this would make handling each case differently quite straight-forward e.g. for web vs CLI.
from addons-linter.
I'm assuming this is all about validation errors (not coding errors 😄).
Agreed, a ValidationError
object we use makes sense, but throwing an actual Exception
/Error
seems like the wrong idea. I'm of the mind that exceptions are for programming errors/unexpected inputs and a validation error isn't the same thing. Code that doesn't pass is expected (and probably common) input. I'd imagine instead any validator method would return (in its resolved Promise) an object with an array or warnings
, errors
, etc. Probably a simple passesValidation()
method too so we can quickly check: is it valid (even if it had warnings but no errors)?
Without getting too deep into the API of a validate()
method, I'd imagine it returns (a Promise) with a list of errors/warnings. eg:
validateFile(myFile).then(function(results) {
if (results.passesValidation()) {
console.log(results.errors);
// null
console.log(results.warnings);
// [ValidationWarning]
console.log(results.warnings[0].message, results.warnings[0].lineNumber);
// "You didn't use a semicolon.", 72
alert("Your add-on is the bee's knees.");
} else {
// Add-on validation failed.
console.log(results.errors);
// [ValidationError, ValidationError];
console.log(results.warnings);
// [ValidationWarning];
}
});
from addons-linter.
Yeah, good point - so the additional consideration is that we don't want to necessarily blow-up on the first issue we come across we need to collect up errors/warnings and display them at the end.
So we have a couple of distinct classes to think about:
App Errors:
- Programming errors (unexpected issues)
- App errors e.g. fatal errors from running the code (e.g. a zip can't be unpacked at all).
Validation output:
- Validation warnings.
- Validation errors.
The first being more likely to be exception based - the latter something like a list of objects that we can process at the end. Albeit in some case we might not complete the entire validation run because of an earlier error.
from addons-linter.
Definitely. The first set being exceptions sounds right to me too; we can't continue on a zip file error, which feels more like an exceptional.
The error and warning classes can probably extend a base "ValidatorMessage" or whatever. Only real difference would be that warnings are okay but errors mean an instant fail for validation.
- tofumatt (Sent from mobile)
On 28 Sep 2015, 15:53 +0100, Stuart [email protected], wrote:
Yeah, good point - so the additional consideration is that we don't want to necessarily blow-up on the first issue we come across we need to collect up errors/warnings and display them at the end.
So we have a couple of distinct classes to think about:
App Errors:
Programming errors (unexpected issues)
App errors e.g. fatal errors from running the code (e.g. a zip can't be unpacked at all).Validation output:
Validation warnings.
Validation errors.The first being more likely to be exception based - the latter something like a list of objects that we can process at the end. Albeit in some case we might not complete the entire validation run because of an earlier error.
—
Reply to this email directly orview it on GitHub(#12 (comment)).
from addons-linter.
Ok I think we're good here. Closing.
from addons-linter.
Related Issues (20)
- Firefox 117 schema HOT 3
- Mozilla
- Import Firefox 118 schema
- Import Firefox 119 schema HOT 1
- Declaring gecko_android in a manifest breaks old versions of Firefox HOT 16
- Unexpected KEY_FIREFOX_ANDROID_UNSUPPORTED_BY_MIN_VERSION warning for features from version range [69, 78] HOT 1
- Allow CSS nesting
- Report a warning on manifest_version 3 targeting Firefox for Android
- Add link to additional docs related to limitations in the MV3 implementation on Firefox for Android
- Import Firefox 120 schema HOT 1
- Import Firefox 121 schema HOT 1
- Mozilla
- Import Firefox 122 schema
- Upload your add-on package: manifest.json was not found HOT 1
- Return a warning for the `service_worker` property
- Import Firefox 123 schema HOT 1
- Remove unused markdown-it-emoji dependency
- Validation error when strict_min_version contains `.1` etc. HOT 4
- Add-on with i18n message in CSS gets validation warning HOT 2
- TypeError: policy.toLowerCase is not a function
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from addons-linter.