errational 0.7.1 → 0.8.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +3 -0
- data/Gemfile +1 -1
- data/README.md +137 -0
- data/errational-0.7.1.gem +0 -0
- data/errational.gemspec +1 -0
- data/lib/errational/errationality.rb +11 -1
- data/lib/errational/version.rb +1 -1
- data/lib/generators/templates/_error_dialog.js.erb +2 -2
- data/lib/generators/templates/exception_module.rb +1 -1
- data/test/errational_test.rb +3 -3
- data/test/errationality_test.rb +24 -3
- data/test/generators/install_generator_test.rb +5 -2
- data/test/{tmp → rails_app}/app/views/errational/_error_dialog.js.erb +2 -2
- data/test/rails_app/config/initializers/errational_configuration.rb +13 -1
- data/test/{tmp → rails_app}/lib/errational/rails_app_error.rb +1 -0
- data/test/{tmp → rails_app}/lib/errational/rails_app_exception.rb +1 -1
- metadata +48 -36
- data/Gemfile.lock +0 -80
- data/README +0 -0
- data/test/rails_app/app/views/_error_dialog.js.erb +0 -1
- data/test/rails_app/lib/rails_app_error.rb +0 -54
- data/test/rails_app/lib/rails_app_exception.rb +0 -25
- data/test/tmp/config/initializers/errational_configuration.rb +0 -18
data/.gitignore
ADDED
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
# errational
|
2
|
+
|
3
|
+
Supports Rails 3 only
|
4
|
+
|
5
|
+
## Summary
|
6
|
+
|
7
|
+
This gem will create custom Exception classes for your rails app,
|
8
|
+
rescue from them whenever they are raised, and display a nice message to the user.
|
9
|
+
|
10
|
+
## Install
|
11
|
+
|
12
|
+
Add to your Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'errational'
|
16
|
+
```
|
17
|
+
|
18
|
+
## Run Generators
|
19
|
+
|
20
|
+
```bash
|
21
|
+
$ rails generate errational:install <app_name>
|
22
|
+
```
|
23
|
+
|
24
|
+
This will generate three files, there is documentation within the generated files:
|
25
|
+
> lib/errational/<app_name>_error.rb
|
26
|
+
> lib/errational/<app_name>_exception.rb
|
27
|
+
> config/initializers/errational_configuration.rb
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
This gem will generate exception classes based on the error constants defined in the generated
|
32
|
+
<app_name>_error.rb file. It will also rescue from these custom exceptions and use the custom defined method of displaying
|
33
|
+
the string of the constant to the user. It also rescues from all Exceptions and if the exception is not one of the
|
34
|
+
custom exception classes, it will display the message from the ApplicationError::General::UNEXPECTED constant.
|
35
|
+
|
36
|
+
This module contains modules of error constants, from each constant an exception class will be generated.
|
37
|
+
Each submodule will be created as a class; it will be used as an intermediate ancestor between the exception class
|
38
|
+
and the application exception class. All error constants must be within a module.
|
39
|
+
|
40
|
+
The constant General::UNEXPECTED is special. This is the message that will be used for all exceptions that are caught
|
41
|
+
that are not from the custom exception classes.
|
42
|
+
|
43
|
+
The module Loggable is a special case. All error constants defined under Loggable (they can be within submodules)
|
44
|
+
will be logged using the Logger defined in the configuration.
|
45
|
+
|
46
|
+
For example, where Application is the name of the application:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
module ApplicationError
|
50
|
+
|
51
|
+
module General
|
52
|
+
UNEXPECTED = "An error has occurred in the application. Please try again."
|
53
|
+
end
|
54
|
+
|
55
|
+
module Loggable
|
56
|
+
SERVICE_FAULT = "The response from the service cannot be processed. Please try again"
|
57
|
+
end
|
58
|
+
|
59
|
+
module Serious
|
60
|
+
BAD_PROBLEM = "The server is on fire, please call the fire department"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
class FirstController < ApplicationController
|
65
|
+
def index
|
66
|
+
raise ApplicationException::ServiceFault # Will automatically be handled by the error handling gem with corresponding message.
|
67
|
+
end
|
68
|
+
|
69
|
+
def create
|
70
|
+
raise RuntimeError # Will automatically be handled by error handling gem with UNEXPECTED message.
|
71
|
+
end
|
72
|
+
|
73
|
+
def update
|
74
|
+
raise ApplicationException::BadProblem
|
75
|
+
rescue ApplicationException::Parent => e # Will rescue any of the exceptions generated by the plugin.
|
76
|
+
if(e.is_a? ApplicationException::Serious) # Sub modules are created as ancestor classes of exceptions, useful for special casing.
|
77
|
+
call_lead_developer
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
```
|
82
|
+
The exception module generated into lib/errational/<app_name>_exception.rb is where you can override the default
|
83
|
+
behavior of exception classes or add other exception classes. The default behavior of the exception classes is to
|
84
|
+
create an exception with the message of the constant. Exception classes that override generated exception classes
|
85
|
+
must be defined as children of their parent module's generated class.
|
86
|
+
|
87
|
+
|
88
|
+
Example:
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
module ApplicationException
|
92
|
+
include Errationalify
|
93
|
+
|
94
|
+
class ServiceFault < Loggable
|
95
|
+
def initialize(service_name)
|
96
|
+
message = sprintf(ApplicationError::SERVICE_FAULT, service_name)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
module ApplicationError
|
101
|
+
module General
|
102
|
+
UNEXPECTED = "An error has occurred in the application. Please try again."
|
103
|
+
end
|
104
|
+
module Loggable
|
105
|
+
SERVICE_FAULT = "The response from %s cannot be processed. Please try again"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
## Configuration
|
111
|
+
|
112
|
+
In the file generated into config/initializers/errational_configuration.rb you will find several values that are
|
113
|
+
configurable.
|
114
|
+
|
115
|
+
The error partial is the path to the partial that will be rendered as the result of xhr actions that result in an
|
116
|
+
exception being thrown. The default error dialog requires jQuery >= 1.5 and jQuery UI >= 1.8.9. The error dialog will
|
117
|
+
be created with an id of errational_error_dialog and a class of errational_class. These can be styled.
|
118
|
+
|
119
|
+
Example:
|
120
|
+
|
121
|
+
``` ruby
|
122
|
+
Errational.setup do |config|
|
123
|
+
# Namespace for name of exception and error modules, based on the name given at install time.
|
124
|
+
# Note, if changing, change the module names in lib/namespace_error.rb and lib/namespace_exception.rb,
|
125
|
+
# , as well as the filenames
|
126
|
+
config.namespace = "Application"
|
127
|
+
|
128
|
+
# The response code given for exceptions that are handled.
|
129
|
+
config.error_response_code = 203
|
130
|
+
|
131
|
+
# The partial to be used for exceptions handled as the result of xhr actions
|
132
|
+
config.error_partial = '/errational/error_dialog'
|
133
|
+
|
134
|
+
# The logger to be used for NamespaceException::Loggable exceptions and unexpected exceptions
|
135
|
+
config.logger = Rails.logger
|
136
|
+
end
|
137
|
+
```
|
Binary file
|
data/errational.gemspec
CHANGED
@@ -10,6 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["errational@surrationale.net"]
|
11
11
|
s.summary = %q{A gem for nice exception handling.}
|
12
12
|
s.description = %q{Nice error handling}
|
13
|
+
s.homepage = "https://github.com/kategengler/errational"
|
13
14
|
|
14
15
|
s.rubyforge_project = "errational"
|
15
16
|
|
@@ -15,7 +15,17 @@ module Errationality
|
|
15
15
|
if request.xhr?
|
16
16
|
render :partial => Errational.error_partial, :status => Errational.error_response_code, :locals => {:message => message}
|
17
17
|
else
|
18
|
-
|
18
|
+
respond_to do |format|
|
19
|
+
format.text do
|
20
|
+
render :text => message, :status => Errational.error_response_code
|
21
|
+
end
|
22
|
+
format.html do
|
23
|
+
render :text => message, :status => Errational.error_response_code
|
24
|
+
end
|
25
|
+
format.json do
|
26
|
+
render :json => message, :status => Errational.error_response_code
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
data/lib/errational/version.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
*/
|
7
7
|
jQuery('body').append('<div id="errational_error_dialog"></div>');
|
8
8
|
jQuery('#errational_error_dialog')
|
9
|
-
.html('<%%= message %>')
|
9
|
+
.html('<%%= message.html_safe %>')
|
10
10
|
.dialog(
|
11
11
|
{
|
12
12
|
minHeight: 'auto',
|
@@ -17,4 +17,4 @@ jQuery('#errational_error_dialog')
|
|
17
17
|
resizable: false,
|
18
18
|
width: 450
|
19
19
|
}
|
20
|
-
);
|
20
|
+
);
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Exception classes that override generated exception classes must be defined as children of their parent module's generated class.
|
4
4
|
# Example:
|
5
5
|
# module ApplicationException
|
6
|
-
# include
|
6
|
+
# include Errationalify
|
7
7
|
#
|
8
8
|
# class ServiceFault < Loggable
|
9
9
|
# def initialize(service_name)
|
data/test/errational_test.rb
CHANGED
@@ -13,11 +13,11 @@ class ErrationalTest < ActiveSupport::TestCase
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_error_base_name
|
16
|
-
assert_equal Errational.error_base_name
|
16
|
+
assert_equal "RailsAppError", Errational.error_base_name
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_exception_base_name
|
20
|
-
assert_equal Errational.exception_base_name
|
20
|
+
assert_equal "RailsAppException", Errational.exception_base_name
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_error_base
|
@@ -48,4 +48,4 @@ class ErrationalTest < ActiveSupport::TestCase
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
end
|
51
|
+
end
|
data/test/errationality_test.rb
CHANGED
@@ -9,7 +9,15 @@ class TestApplicationController < ApplicationController
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def index
|
12
|
-
|
12
|
+
respond_to do |format|
|
13
|
+
format.text do
|
14
|
+
render :text => "hello"
|
15
|
+
end
|
16
|
+
|
17
|
+
format.json do
|
18
|
+
render :json => {:blah =>'foo'}
|
19
|
+
end
|
20
|
+
end
|
13
21
|
end
|
14
22
|
end
|
15
23
|
|
@@ -34,6 +42,12 @@ class ErrationalityTest < ActionController::TestCase
|
|
34
42
|
assert_match /#{Errational.error_base::UNEXPECTED}/, @response.body
|
35
43
|
end
|
36
44
|
|
45
|
+
def test_should_render_error_in_format_requested
|
46
|
+
@controller.stubs(:blah).raises(RuntimeError)
|
47
|
+
get :index, :format => :json
|
48
|
+
assert_equal("application/json", @response.content_type)
|
49
|
+
end
|
50
|
+
|
37
51
|
def test_should_have_error_response_code_for_full_request
|
38
52
|
@controller.stubs(:blah).raises(RuntimeError)
|
39
53
|
get :index
|
@@ -49,7 +63,7 @@ class ErrationalityTest < ActionController::TestCase
|
|
49
63
|
def test_handle_exception_renders_error_dialog_partial
|
50
64
|
@controller.stubs(:blah).raises(RuntimeError)
|
51
65
|
xhr :get, :index
|
52
|
-
assert_match
|
66
|
+
assert_match /#{Errational.error_base::UNEXPECTED}/, @response.body
|
53
67
|
end
|
54
68
|
|
55
69
|
def test_handle_unexpected_exception_handles_general_exceptions_raises_tac_retry_message_and_logs
|
@@ -59,6 +73,13 @@ class ErrationalityTest < ActionController::TestCase
|
|
59
73
|
@controller.send(:handle_unexpected_exception, new_exception)
|
60
74
|
end
|
61
75
|
|
76
|
+
def test_messages_are_html_safe_as_default
|
77
|
+
new_exception = RailsAppException::HtmlMessage
|
78
|
+
@controller.stubs(:blah).raises(new_exception)
|
79
|
+
xhr :get, :index
|
80
|
+
assert_match /#{RailsAppError::HTML_MESSAGE}/, @response.body
|
81
|
+
end
|
82
|
+
|
62
83
|
private
|
63
84
|
|
64
85
|
def assert_controller_handles_exception_with(exception, method)
|
@@ -66,4 +87,4 @@ class ErrationalityTest < ActionController::TestCase
|
|
66
87
|
@controller.stubs(:blah).raises(exception, "a message")
|
67
88
|
xhr :get, :index
|
68
89
|
end
|
69
|
-
end
|
90
|
+
end
|
@@ -4,7 +4,10 @@ class InstallGeneratorTest < Rails::Generators::TestCase
|
|
4
4
|
tests Errational::Generators::InstallGenerator
|
5
5
|
destination File.expand_path("../../tmp", __FILE__)
|
6
6
|
|
7
|
-
setup
|
7
|
+
def setup
|
8
|
+
$stderr.stubs(:write)
|
9
|
+
prepare_destination
|
10
|
+
end
|
8
11
|
|
9
12
|
def test_assert_all_files_are_properly_created
|
10
13
|
run_generator ["RailsApp"]
|
@@ -13,4 +16,4 @@ class InstallGeneratorTest < Rails::Generators::TestCase
|
|
13
16
|
assert_file "lib/errational/rails_app_exception.rb"
|
14
17
|
assert_file "app/views/errational/_error_dialog.js.erb"
|
15
18
|
end
|
16
|
-
end
|
19
|
+
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
*/
|
7
7
|
jQuery('body').append('<div id="errational_error_dialog"></div>');
|
8
8
|
jQuery('#errational_error_dialog')
|
9
|
-
.html('<%= message %>')
|
9
|
+
.html('<%= message.html_safe %>')
|
10
10
|
.dialog(
|
11
11
|
{
|
12
12
|
minHeight: 'auto',
|
@@ -17,4 +17,4 @@ jQuery('#errational_error_dialog')
|
|
17
17
|
resizable: false,
|
18
18
|
width: 450
|
19
19
|
}
|
20
|
-
);
|
20
|
+
);
|
@@ -1,6 +1,18 @@
|
|
1
|
+
#TODO is this the best place for this line?
|
2
|
+
ActiveSupport::Dependencies.autoload_paths << "#{Rails.root}/lib/errational"
|
3
|
+
|
1
4
|
Errational.setup do |config|
|
5
|
+
# Namespace for name of exception and error modules, based on the name given at install time.
|
6
|
+
# Note, if changing, change the module names in lib/namespace_error.rb and lib/namespace_exception.rb,
|
7
|
+
# , as well as the filenames
|
2
8
|
config.namespace = "RailsApp"
|
9
|
+
|
10
|
+
# The response code given for exceptions that are handled.
|
3
11
|
config.error_response_code = 203
|
4
|
-
|
12
|
+
|
13
|
+
# The partial to be used for exceptions handled as the result of xhr actions
|
14
|
+
config.error_partial = '/errational/error_dialog'
|
15
|
+
|
16
|
+
# The logger to be used for NamespaceException::Loggable exceptions and unexpected exceptions
|
5
17
|
config.logger = Rails.logger
|
6
18
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# Exception classes that override generated exception classes must be defined as children of their parent module's generated class.
|
4
4
|
# Example:
|
5
5
|
# module ApplicationException
|
6
|
-
# include
|
6
|
+
# include Errationalify
|
7
7
|
#
|
8
8
|
# class ServiceFault < Loggable
|
9
9
|
# def initialize(service_name)
|
metadata
CHANGED
@@ -1,29 +1,40 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: errational
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
- 16
|
10
|
+
version: 0.8.16
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Kate Gengler
|
9
14
|
- Brian Olore
|
10
15
|
autorequire:
|
11
16
|
bindir: bin
|
12
17
|
cert_chain: []
|
13
|
-
|
18
|
+
|
19
|
+
date: 2011-08-16 00:00:00 -04:00
|
14
20
|
default_executable:
|
15
21
|
dependencies: []
|
22
|
+
|
16
23
|
description: Nice error handling
|
17
|
-
email:
|
24
|
+
email:
|
18
25
|
- errational@surrationale.net
|
19
26
|
executables: []
|
27
|
+
|
20
28
|
extensions: []
|
29
|
+
|
21
30
|
extra_rdoc_files: []
|
22
|
-
|
31
|
+
|
32
|
+
files:
|
33
|
+
- .gitignore
|
23
34
|
- Gemfile
|
24
|
-
-
|
25
|
-
- README
|
35
|
+
- README.md
|
26
36
|
- Rakefile
|
37
|
+
- errational-0.7.1.gem
|
27
38
|
- errational.gemspec
|
28
39
|
- lib/errational.rb
|
29
40
|
- lib/errational/errationalify.rb
|
@@ -44,7 +55,7 @@ files:
|
|
44
55
|
- test/rails_app/Rakefile
|
45
56
|
- test/rails_app/app/controllers/application_controller.rb
|
46
57
|
- test/rails_app/app/helpers/application_helper.rb
|
47
|
-
- test/rails_app/app/views/_error_dialog.js.erb
|
58
|
+
- test/rails_app/app/views/errational/_error_dialog.js.erb
|
48
59
|
- test/rails_app/app/views/layouts/application.html.erb
|
49
60
|
- test/rails_app/config.ru
|
50
61
|
- test/rails_app/config/application.rb
|
@@ -64,8 +75,8 @@ files:
|
|
64
75
|
- test/rails_app/config/routes.rb
|
65
76
|
- test/rails_app/db/seeds.rb
|
66
77
|
- test/rails_app/doc/README_FOR_APP
|
67
|
-
- test/rails_app/lib/rails_app_error.rb
|
68
|
-
- test/rails_app/lib/rails_app_exception.rb
|
78
|
+
- test/rails_app/lib/errational/rails_app_error.rb
|
79
|
+
- test/rails_app/lib/errational/rails_app_exception.rb
|
69
80
|
- test/rails_app/lib/tasks/.gitkeep
|
70
81
|
- test/rails_app/public/404.html
|
71
82
|
- test/rails_app/public/422.html
|
@@ -85,36 +96,41 @@ files:
|
|
85
96
|
- test/rails_app/test/test_helper.rb
|
86
97
|
- test/rails_app/vendor/plugins/.gitkeep
|
87
98
|
- test/test_helper.rb
|
88
|
-
- test/tmp/app/views/errational/_error_dialog.js.erb
|
89
|
-
- test/tmp/config/initializers/errational_configuration.rb
|
90
|
-
- test/tmp/lib/errational/rails_app_error.rb
|
91
|
-
- test/tmp/lib/errational/rails_app_exception.rb
|
92
99
|
has_rdoc: true
|
93
|
-
homepage:
|
100
|
+
homepage: https://github.com/kategengler/errational
|
94
101
|
licenses: []
|
102
|
+
|
95
103
|
post_install_message:
|
96
104
|
rdoc_options: []
|
97
|
-
|
105
|
+
|
106
|
+
require_paths:
|
98
107
|
- lib
|
99
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
109
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
hash: 3
|
114
|
+
segments:
|
115
|
+
- 0
|
116
|
+
version: "0"
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
118
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
hash: 3
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
111
126
|
requirements: []
|
127
|
+
|
112
128
|
rubyforge_project: errational
|
113
129
|
rubygems_version: 1.6.2
|
114
130
|
signing_key:
|
115
131
|
specification_version: 3
|
116
132
|
summary: A gem for nice exception handling.
|
117
|
-
test_files:
|
133
|
+
test_files:
|
118
134
|
- test/errational_test.rb
|
119
135
|
- test/errationalify_test.rb
|
120
136
|
- test/errationality_test.rb
|
@@ -124,7 +140,7 @@ test_files:
|
|
124
140
|
- test/rails_app/Rakefile
|
125
141
|
- test/rails_app/app/controllers/application_controller.rb
|
126
142
|
- test/rails_app/app/helpers/application_helper.rb
|
127
|
-
- test/rails_app/app/views/_error_dialog.js.erb
|
143
|
+
- test/rails_app/app/views/errational/_error_dialog.js.erb
|
128
144
|
- test/rails_app/app/views/layouts/application.html.erb
|
129
145
|
- test/rails_app/config.ru
|
130
146
|
- test/rails_app/config/application.rb
|
@@ -144,8 +160,8 @@ test_files:
|
|
144
160
|
- test/rails_app/config/routes.rb
|
145
161
|
- test/rails_app/db/seeds.rb
|
146
162
|
- test/rails_app/doc/README_FOR_APP
|
147
|
-
- test/rails_app/lib/rails_app_error.rb
|
148
|
-
- test/rails_app/lib/rails_app_exception.rb
|
163
|
+
- test/rails_app/lib/errational/rails_app_error.rb
|
164
|
+
- test/rails_app/lib/errational/rails_app_exception.rb
|
149
165
|
- test/rails_app/lib/tasks/.gitkeep
|
150
166
|
- test/rails_app/public/404.html
|
151
167
|
- test/rails_app/public/422.html
|
@@ -165,7 +181,3 @@ test_files:
|
|
165
181
|
- test/rails_app/test/test_helper.rb
|
166
182
|
- test/rails_app/vendor/plugins/.gitkeep
|
167
183
|
- test/test_helper.rb
|
168
|
-
- test/tmp/app/views/errational/_error_dialog.js.erb
|
169
|
-
- test/tmp/config/initializers/errational_configuration.rb
|
170
|
-
- test/tmp/lib/errational/rails_app_error.rb
|
171
|
-
- test/tmp/lib/errational/rails_app_exception.rb
|
data/Gemfile.lock
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
errational (0.7.1)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
abstract (1.0.0)
|
10
|
-
actionmailer (3.0.7)
|
11
|
-
actionpack (= 3.0.7)
|
12
|
-
mail (~> 2.2.15)
|
13
|
-
actionpack (3.0.7)
|
14
|
-
activemodel (= 3.0.7)
|
15
|
-
activesupport (= 3.0.7)
|
16
|
-
builder (~> 2.1.2)
|
17
|
-
erubis (~> 2.6.6)
|
18
|
-
i18n (~> 0.5.0)
|
19
|
-
rack (~> 1.2.1)
|
20
|
-
rack-mount (~> 0.6.14)
|
21
|
-
rack-test (~> 0.5.7)
|
22
|
-
tzinfo (~> 0.3.23)
|
23
|
-
activemodel (3.0.7)
|
24
|
-
activesupport (= 3.0.7)
|
25
|
-
builder (~> 2.1.2)
|
26
|
-
i18n (~> 0.5.0)
|
27
|
-
activerecord (3.0.7)
|
28
|
-
activemodel (= 3.0.7)
|
29
|
-
activesupport (= 3.0.7)
|
30
|
-
arel (~> 2.0.2)
|
31
|
-
tzinfo (~> 0.3.23)
|
32
|
-
activeresource (3.0.7)
|
33
|
-
activemodel (= 3.0.7)
|
34
|
-
activesupport (= 3.0.7)
|
35
|
-
activesupport (3.0.7)
|
36
|
-
arel (2.0.10)
|
37
|
-
builder (2.1.2)
|
38
|
-
erubis (2.6.6)
|
39
|
-
abstract (>= 1.0.0)
|
40
|
-
i18n (0.5.0)
|
41
|
-
mail (2.2.19)
|
42
|
-
activesupport (>= 2.3.6)
|
43
|
-
i18n (>= 0.4.0)
|
44
|
-
mime-types (~> 1.16)
|
45
|
-
treetop (~> 1.4.8)
|
46
|
-
mime-types (1.16)
|
47
|
-
mocha (0.9.12)
|
48
|
-
polyglot (0.3.1)
|
49
|
-
rack (1.2.3)
|
50
|
-
rack-mount (0.6.14)
|
51
|
-
rack (>= 1.0.0)
|
52
|
-
rack-test (0.5.7)
|
53
|
-
rack (>= 1.0)
|
54
|
-
rails (3.0.7)
|
55
|
-
actionmailer (= 3.0.7)
|
56
|
-
actionpack (= 3.0.7)
|
57
|
-
activerecord (= 3.0.7)
|
58
|
-
activeresource (= 3.0.7)
|
59
|
-
activesupport (= 3.0.7)
|
60
|
-
bundler (~> 1.0)
|
61
|
-
railties (= 3.0.7)
|
62
|
-
railties (3.0.7)
|
63
|
-
actionpack (= 3.0.7)
|
64
|
-
activesupport (= 3.0.7)
|
65
|
-
rake (>= 0.8.7)
|
66
|
-
thor (~> 0.14.4)
|
67
|
-
rake (0.8.7)
|
68
|
-
thor (0.14.6)
|
69
|
-
treetop (1.4.9)
|
70
|
-
polyglot (>= 0.3.1)
|
71
|
-
tzinfo (0.3.29)
|
72
|
-
|
73
|
-
PLATFORMS
|
74
|
-
ruby
|
75
|
-
|
76
|
-
DEPENDENCIES
|
77
|
-
errational!
|
78
|
-
mocha (= 0.9.12)
|
79
|
-
rails (= 3.0.7)
|
80
|
-
rake (= 0.8.7)
|
data/README
DELETED
File without changes
|
@@ -1 +0,0 @@
|
|
1
|
-
new ErrorDialog({"message": "<%= message %>"});
|
@@ -1,54 +0,0 @@
|
|
1
|
-
# This module contains modules of error constants, from each constant an exception class will be generated.
|
2
|
-
# Each submodule will be created as a class; it will be used as an intermediate ancestor between the exception class
|
3
|
-
# and the application exception class.
|
4
|
-
# For example, where Application is the name of the application:
|
5
|
-
# module ApplicationError
|
6
|
-
# module General
|
7
|
-
# UNEXPECTED = "An error has occured in the application. Please try again."
|
8
|
-
# end
|
9
|
-
# module Loggable
|
10
|
-
# SERVICE_FAULT = "The response from the service cannot be processed. Please try again"
|
11
|
-
# end
|
12
|
-
# module Serious
|
13
|
-
# BAD_PROBLEM = "The server is on fire, please call the fire department"
|
14
|
-
# end
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# class FirstController < ApplicationController
|
18
|
-
# def index
|
19
|
-
# raise ApplicationException::ServiceFault # Will automatically be handled by the error handling gem with corresponding message.
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# def create
|
23
|
-
# raise RuntimeError # Will automatically be handled by error handling gem with UNEXPECTED message.
|
24
|
-
# end
|
25
|
-
#
|
26
|
-
# def update
|
27
|
-
# raise ApplicationException::BadProblem
|
28
|
-
# rescue ApplicationException::Parent => e # Will rescue any of the exceptions generated by the plugin.
|
29
|
-
# if(e.is_a? ApplicationException::Serious) # Sub modules are created as ancestor classes of exceptions, useful for special casing.
|
30
|
-
# call_lead_developer
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
module RailsAppError
|
36
|
-
|
37
|
-
module General
|
38
|
-
# Default message for all general exceptions.
|
39
|
-
# Unexpected exceptions (ones without specific exception classes) will be logged.
|
40
|
-
UNEXPECTED = "An error has occurred with your last request. Please try again."
|
41
|
-
end
|
42
|
-
|
43
|
-
#Errors in this module will be logged
|
44
|
-
module Loggable
|
45
|
-
LOG_THIS = "This is a really bad error. Tell someone!"
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
def self.include_all_of_own_modules
|
50
|
-
constants.map { |c| const_get(c) }.select { |c| Module === c }.each { |c| include c }
|
51
|
-
end
|
52
|
-
|
53
|
-
include_all_of_own_modules
|
54
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# This module is where you can override the default behavior of exception classes or add other exception classes.
|
2
|
-
# The default behavior of the exception classes is to create an exception with the message of the constant.
|
3
|
-
# Exception classes that override generated exception classes must be defined as children of their parent module's generated class.
|
4
|
-
# Example:
|
5
|
-
# module ApplicationException
|
6
|
-
# include ErrorHandlingClass
|
7
|
-
#
|
8
|
-
# class ServiceFault < Loggable
|
9
|
-
# def initialize(service_name)
|
10
|
-
# message = sprintf(ApplicationError::SERVICE_FAULT, service_name)
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
# end
|
14
|
-
# module ApplicationError
|
15
|
-
# module General
|
16
|
-
# UNEXPECTED = "An error has occured in the application. Please try again."
|
17
|
-
# end
|
18
|
-
# module Loggable
|
19
|
-
# SERVICE_FAULT = "The response from %s cannot be processed. Please try again"
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
|
23
|
-
module RailsAppException
|
24
|
-
include Errationalify
|
25
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
#TODO is this the best place for this line?
|
2
|
-
ActiveSupport::Dependencies.autoload_paths << "#{Rails.root}/lib/errational"
|
3
|
-
|
4
|
-
Errational.setup do |config|
|
5
|
-
# Namespace for name of exception and error modules, based on the name given at install time.
|
6
|
-
# Note, if changing, change the module names in lib/namespace_error.rb and lib/namespace_exception.rb,
|
7
|
-
# , as well as the filenames
|
8
|
-
config.namespace = "RailsApp"
|
9
|
-
|
10
|
-
# The response code given for exceptions that are handled.
|
11
|
-
config.error_response_code = 203
|
12
|
-
|
13
|
-
# The partial to be used for exceptions handled as the result of xhr actions
|
14
|
-
config.error_partial = '/errational/error_dialog'
|
15
|
-
|
16
|
-
# The logger to be used for NamespaceException::Loggable exceptions and unexpected exceptions
|
17
|
-
config.logger = Rails.logger
|
18
|
-
end
|