Building a better system for warnings and errors in ember js


#1

Bringing discussion over to forum from github issues.

More detail here.

Key idea: with a little more convention and a few high level methods we could have a way to provide hooks in the system to give novice users powerful tools to debug and efficiently interpret the warnings that might arise in day to day development.

Provide easy to review system of all warning message and ensure highest level of consistency, accuracy, and usefulness of warning messages.

Would like to discuss a high level potential API, and what others might feel is the utility of the providing warnings with detailed context.

Core requirements:

  • When issuing warnings in core ember provide hook to reference context, e.g. where in source code did warning come from? Github line number source code links?

  • Centrally register all warning/error codes, abstract warning code from warning content

  • All warnings should have unique code

  • Warning codes should be treated as constants and not mutable at runtime.

  • Provide mechanism to link to or easily reference detailed help guides to explain potential cause of warnings. Give user tool to quickly debug why their code is not working. Provide much more info that can reasonably be shoved into string in source code.

  • Provide infrastructure to easily localize warning messages.

  • Enforce convention in all source code development to use registered warning convention.

It is recognized that this is a change that touches a lot of code and it is probably suitable for 2.0 release cycle.

Potential API

Ember.Logger.warn.detailed("This is the warning", EMBER-WARN-123);

and then elsewhere in the source is a registry with that warning code 

EMBER-WARN-123 

could map to hash with specific details about 
where and why the message was raised.

Thoughts?