File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,12 @@ function outward_res_object(ctxt, data) {
107
107
! ! res . force$
108
108
)
109
109
110
+ // Responding with an Error as data is not allowed.
111
+ // https://github.com/senecajs/seneca/issues/711
112
+ if ( data . out instanceof Error ) {
113
+ not_object = true
114
+ }
115
+
110
116
var not_legacy = ! (
111
117
msg . cmd === 'generate_id' ||
112
118
msg . note === true ||
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ var arrayify = Function.prototype.apply.bind(Array.prototype.slice)
21
21
var make_test_transport = TransportStubs . make_test_transport
22
22
23
23
describe ( 'error' , function ( ) {
24
+ it ( 'response_is_error' , response_is_error )
24
25
it ( 'action_callback' , action_callback )
25
26
it ( 'plugin_load' , plugin_load )
26
27
@@ -45,6 +46,28 @@ describe('error', function() {
45
46
46
47
it ( 'legacy_fail' , legacy_fail )
47
48
49
+
50
+ function response_is_error ( fin ) {
51
+ var si = Seneca ( { log : 'silent' } )
52
+
53
+ si . add ( 'a:1' , function ( msg , reply ) {
54
+ var foo = new Error ( 'foo' )
55
+ foo . a = 1
56
+ reply ( null , foo )
57
+ } )
58
+
59
+ si . error ( function ( err ) {
60
+ expect ( err . code ) . equal ( 'result_not_objarr' )
61
+ fin ( )
62
+ } )
63
+
64
+ si . act ( 'a:1' , function ( err , out ) {
65
+ expect ( out ) . not . exist ( )
66
+ expect ( err . code ) . equal ( 'result_not_objarr' )
67
+ } )
68
+ }
69
+
70
+
48
71
function action_callback ( fin ) {
49
72
var si = Seneca ( { log : 'silent' } )
50
73
You can’t perform that action at this time.
0 commit comments