-
Notifications
You must be signed in to change notification settings - Fork 17
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
Is there a way to hook into PTT warnings #204
Comments
There are two possible solutions:
Probably the best solution is to provide an optional setting for whether to throw errors or show console messages (or neither). |
Maybe a third solution is to save the error state in code somewhere. Like |
Maybe another solution is to pass a warnings handler function into options and the default warnings handler is to console.warn() like you do now, but if I've passed one use that instead? |
You could also have methods like validateTags() which could return a result for each type of issue. I guess there are many more than 2 possible solutions! These are all pretty easy to add. Here's what I'd propose:
|
Sounds fine |
Added errorHandler and supressConsole as options. errorHandler will be called whenever there's an internal warning in the code such as an invalid color. re #204
Created a dummy console to supress warnings in the console when running tests re #204
@rizen Currently, there are only a handful of situations where you will receive one of these warnings, that is, any time when you would have gotten I hadn't given this topic a whole lot of thought in the past but there should probably be a rule like "if it only breaks the style, make it a warning not an error". For example, this code currently throws but probably should warn and use the default value "left": throw new Error(
`Unsupported alignment type ${align}! Use one of : "left", "right", "center", "justify"`
); |
Crap. I forgot to add the Update: added in v3.3.1 |
Added a target property for error messages that references the thing that sent the error message. re #204
Note to self, fix warnings on percentage font size |
PTT puts warnings (like unclosed tags) into the console. Is there a way to hook into those so I could display them to the user?
The text was updated successfully, but these errors were encountered: