-
Notifications
You must be signed in to change notification settings - Fork 35
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
Exception handling #49
Open
catmando
wants to merge
7
commits into
zetachang:react-v0.13
Choose a base branch
from
catprintlabs:exception_handling
base: react-v0.13
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
58ea2d1
added observables
catmando 235723f
base for future PRs
catmando ba1465d
updated todo notes
catmando 73bf031
Merge remote-tracking branch 'upstream/react-v0.13' into react-v0.13
catmando 2e1a925
merged
catmando a0c13e8
loosened sprockets dependency, made this base for future PRs
catmando 4f56dc7
added exception handling for exceptions during render
catmando File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
describe "displaying helpful warning and error messages" do | ||
|
||
before(:all) do | ||
%x{ | ||
window.old_error_console = console.error | ||
console.error = function(m) { window.last_error_message = m; } | ||
} | ||
end | ||
|
||
after(:all) do | ||
%x{ | ||
console.error = window.old_error_console | ||
} | ||
end | ||
|
||
it "should print and exception message" do | ||
stub_const 'Foo', Class.new | ||
Foo.class_eval do | ||
include React::Component | ||
def render | ||
raise "error happened" | ||
end | ||
end | ||
React.render_to_static_markup(React.create_element(Foo)) | ||
expect(`window.last_error_message`).to include("error happened") | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
observable_spec.rb | ||
|
||
native_library_spec.rb <- no big interaction, just hooks into @@component_classes - but depends on RenderingContext | ||
|
||
importing native react components (like bootstrap) | ||
|
||
|
||
export_component_spec.rb <- completely stand alone | ||
export_component | ||
|
||
|
||
rendering_context_spec.rb | ||
NOTE: rendering context primarily exists so that we can say Foo::Bar in the dsl, because we have no way of knowing the caller, so we have to track it via RenderingContext | ||
NOTE: put the component lookup method in here I think | ||
components can be directly named in the dsl (i.e. if class Foo, then you can just say Foo) | ||
_as_node will return the native node without pushing into the buffer | ||
if element returned from the child block is a string it is added to the buffer | ||
test to make sure subclassing components works | ||
|
||
exception_handling_spec.rb | ||
you don't have to have render method, if you just want to export state <- not sure what is going on here, but there is a render method now in the component, that raises an error unless its subclassed | ||
catch and print rendering method if rendering fails. | ||
I'm figuring that there will more exception cases (like misnamed components) that can go in this file. | ||
|
||
state_spec.rb | ||
states all get methods - states define methods foo, foo= and foo! | ||
export / import states | ||
states can be defined from within components instances (i.e. before_mount) | ||
define_state extended syntax: strings/symbols are initialized to the default initializer (nil or provided by block), the hash gives name => value pairs | ||
if default initializer excepts params then it is considered a state listener and will receive |state_name, current_value, new_value| on state changes | ||
|
||
|
||
params_spec.rb | ||
NOTE: probably updates validator | ||
can require param on a single line: required_param or optional_param | ||
can require param of type Proc | ||
params get methods | ||
proc params automatically call | ||
ReactObserver params interact with the observer | ||
|
||
|
||
depends on react-source <- does it have to (i.e. perhaps for react-rails to work?, if not then do a separate PR at end) | ||
|
||
Branch map... | ||
|
||
v13_base is synced with v13 BUT already has observable.rb added. (todo if possible, shuffle this around) | ||
<- exception_handling branched fro v13_base | ||
<- export_component branched from v13_base |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
How about just return
null
orundefined
?