Comments (11)
Some users may need even that API representation, which contains errors. That's why we do not reject Promise in this situation.
Is it important for you to have Promise rejected in case of API with errors? If yes, we can introduce a special option for this purpose.
from raml-js-parser-2.
Would that change the high-level Parser API?
from raml-js-parser-2.
@sichvoge A little bit. There will be a new field in
http://raml-org.github.io/raml-js-parser-2/interfaces/_raml1_wrapped_ast_parsercore_.options.html
from raml-js-parser-2.
ok, I agree with having an option for rejecting promises on errors, to cover all possible scenarios
from raml-js-parser-2.
What will the rejected promise look like? Rejections should be error instances, but the parser can return multiple errors. An error will errors on a property, or just the first error instance?
from raml-js-parser-2.
@blakeembrey
For now it's just an error containing a single message. Do you know some Error subclass which can be passed an object (or array) to constructor (just like we pass strings usually)?
from raml-js-parser-2.
There's nothing formal in JavaScript, but you can just do it yourself. You can also subclass Error
if you want to do this in a declarative way (with something like https://github.com/julien-f/js-make-error).
var error = new Error('Invalid RAML')
error.errors = errors // Tada, just document the error type.
return error
from raml-js-parser-2.
Ok, thanks. So, there will be a message Api contains errors.
and a complete array of errors.
from raml-js-parser-2.
@blakeembrey It appears that Error subclassing is not available in typescript 1.4 microsoft/TypeScript#1168.
Seems like it remains to write parser errors to some field of the newly created error.
from raml-js-parser-2.
@KonstantinSviridov I pointed out how you can do it in the comment above.
from raml-js-parser-2.
For loadApi
:
If the 'rejectOnErrors' option is set to true, ApiLoadingError
is thrown for Api which contains errors.
For loadApiAsync
:
The Promise is rejected with ApiLoadingError
if the resulting Api contains errors and the 'rejectOnErrors' option is set to 'true'.
Where ApiLoadingError
is
http://raml-org.github.io/raml-js-parser-2/interfaces/_raml1_wrapped_ast_parsercore_.apiloadingerror.html
from raml-js-parser-2.
Related Issues (20)
- `typings-new-format` are not being exported by index.d.ts HOT 1
- When raml-js-parser-2 is deprecated, what is the next step? HOT 1
- Cannot find module './ast.core/linter' HOT 2
- An in-range update of rimraf is breaking the build 🚨 HOT 3
- ERROR in ./node_modules/raml-1-parser/dist/parser/ast.core/expanderLL.js at compile. HOT 2
- An in-range update of @types/node is breaking the build 🚨 HOT 36
- An in-range update of z-schema is breaking the build 🚨 HOT 2
- An in-range update of @types/chai is breaking the build 🚨 HOT 6
- Problem when parsing !included traits HOT 1
- An in-range update of webpack is breaking the build 🚨 HOT 6
- An in-range update of marked is breaking the build 🚨 HOT 2
- An in-range update of underscore is breaking the build 🚨 HOT 3
- An in-range update of @types/marked is breaking the build 🚨 HOT 1
- An in-range update of ajv is breaking the build 🚨 HOT 2
- An in-range update of @types/invariant is breaking the build 🚨 HOT 1
- An in-range update of @types/underscore is breaking the build 🚨 HOT 1
- An in-range update of @types/node is breaking the build 🚨 HOT 1
- An in-range update of @types/invariant is breaking the build 🚨 HOT 1
- An in-range update of marked is breaking the build 🚨 HOT 1
- xmldom-alpha is no longer maintained HOT 1
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 raml-js-parser-2.