tzispa 0.4.10 → 0.4.11

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6563a94edbe1592bb7dca93f061094b7f545ddb7
4
- data.tar.gz: 20e67059d53a2eace90a4b0f2f5d6445133455b4
3
+ metadata.gz: 9b3b6df11ce0ea41a4e564ec835dd8c98a87218c
4
+ data.tar.gz: 951f7c1e75d68514481c2f81cc5c92d461834bd3
5
5
  SHA512:
6
- metadata.gz: 943d78aa578e90e7e664e1b8d4bafd38b54ba331b67c40c2d60cd5cd7c3d7d86b31b540fcbe4c9bd39f70aeb0ab49e125b7c82100b2a530e58a92514673864f6
7
- data.tar.gz: 4593029b257aaa3fd201a3d5128a385b0f6451326ca6e43a3e302ea23daeecc2aa8a95a5ace2a4d7e2e9ea0faed7ae12afaf77f73207ccc7afc6ce52317c9c4d
6
+ metadata.gz: 031c851c6926cabb3ee2e8f2283b3701d842eba3fd9d607a75b5cfb39604a3acff2d9e9402905063ba6ffd65874c48373fd62eb41b04f22c2ad8ae58cfb930cc
7
+ data.tar.gz: cd1a9dd768e7723b1ae6f50fe3d8a3b63ba8e523aae1dc827e83cc14543dd9755dbc958c3fcf8ca8bf26aca4b8acc3ae7efb36ca24fb9c9af80d84cce7c31fb4
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@ Tzispa
2
2
 
3
3
  General purpose web framework
4
4
 
5
+ ## v0.4.11
6
+ - Rescue exceptions and catch halts on controller/base
7
+ - http/context error_500 not sets response.status
8
+ - Rescue exceptions in app.call only log and set response.status previous code moved to controller/base
9
+
5
10
  ## v0.4.10
6
11
  - http/context api method return a canonical url including hostname
7
12
 
data/lib/tzispa/app.rb CHANGED
@@ -8,7 +8,6 @@ require 'tzispa/routes'
8
8
  require 'tzispa/config/appconfig'
9
9
  require 'tzispa/middleware'
10
10
  require 'tzispa/http/context'
11
- require 'tzispa/helpers/error_view'
12
11
  require 'tzispa_data'
13
12
  require "tzispa_rig"
14
13
 
@@ -22,8 +21,6 @@ module Tzispa
22
21
  class Application
23
22
  extend Forwardable
24
23
 
25
- include Tzispa::Helpers::ErrorView
26
-
27
24
  attr_reader :domain, :config, :middleware, :repository, :engine, :logger
28
25
  def_delegator :@middleware, :use
29
26
  def_delegator :@domain, :name
@@ -76,18 +73,13 @@ module Tzispa
76
73
 
77
74
  def call(env)
78
75
  env[Tzispa::ENV_TZISPA_APP] = self
79
- context = Tzispa::Http::Context.new(env)
80
- env[Tzispa::ENV_TZISPA_CONTEXT] = context
76
+ env[Tzispa::ENV_TZISPA_CONTEXT] = Tzispa::Http::Context.new(env)
81
77
  begin
82
78
  middleware.call(env)
83
- rescue StandardError, ScriptError => ex
84
- logger.error "#{ex.message}\n#{ex.backtrace.map { |trace| "\t #{trace}" }.join('\n') if ex.respond_to?(:backtrace) && ex.backtrace}"
85
- if config.developing
86
- context.error_500 error_report(ex)
87
- else
88
- context.error_500 error_page(domain)
89
- end
90
- context.response.finish
79
+ rescue => ex
80
+ logger.error ex.message
81
+ env[Tzispa::ENV_TZISPA_CONTEXT].response.status = 500
82
+ env[Tzispa::ENV_TZISPA_CONTEXT].response.finish
91
83
  end
92
84
  end
93
85
 
@@ -3,6 +3,7 @@
3
3
  require 'forwardable'
4
4
  require 'tzispa/version'
5
5
  require 'tzispa/rig/template'
6
+ require 'tzispa/helpers/error_view'
6
7
 
7
8
 
8
9
  module Tzispa
@@ -11,6 +12,8 @@ module Tzispa
11
12
  class Base
12
13
  extend Forwardable
13
14
 
15
+ include Tzispa::Helpers::ErrorView
16
+
14
17
  attr_reader :context
15
18
  def_delegators :@context, :request, :response, :config
16
19
 
@@ -28,13 +31,18 @@ module Tzispa
28
31
 
29
32
  def invoke(callmethod)
30
33
  status = catch(:halt) {
31
- send "#{@callmethod}"
34
+ begin
35
+ send "#{@callmethod}"
36
+ rescue StandardError, ScriptError => exx
37
+ context.error_500( config.developing ? debug_info(exx) : nil )
38
+ end
32
39
  }
33
40
  response.status = status if status.is_a?(Integer)
34
- context.error_500 context.app.error_page(context.app.domain, status: response.status) if (response.client_error? || response.server_error?)
41
+ if (response.client_error? || response.server_error?) && !config.developing
42
+ response.body = error_page(context.domain)
43
+ end
35
44
  end
36
45
 
37
-
38
46
  end
39
47
 
40
48
  end
@@ -38,13 +38,6 @@ module Tzispa
38
38
  router_params&.fetch(:layout, nil)
39
39
  end
40
40
 
41
- def error_500(body)
42
- 500.tap { |code|
43
- response.status = code
44
- response.body = body
45
- }
46
- end
47
-
48
41
  def set_last_access
49
42
  session[SESSION_LAST_ACCESS] = Time.now.utc.iso8601
50
43
  end
@@ -73,6 +66,12 @@ module Tzispa
73
66
  session.delete(SESSION_AUTH_USER)
74
67
  end
75
68
 
69
+ def error_500(str)
70
+ 500.tap { |code|
71
+ response.body = str if str
72
+ }
73
+ end
74
+
76
75
  def path(path_id, params={})
77
76
  app.class.routes.path path_id, params
78
77
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tzispa
4
- VERSION = '0.4.10'
4
+ VERSION = '0.4.11'
5
5
  FRAMEWORK_NAME = 'Tzispa'
6
6
  GEM_NAME = 'tzispa'
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tzispa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.10
4
+ version: 0.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Antonio Piñero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-19 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack