@@ -25,7 +25,7 @@ module.exports = function (chain, chaincode_id, logger) {
2525 function ( results ) {
2626 var proposalResponses = results [ 0 ] ;
2727 var proposal = results [ 1 ] ;
28- if ( proposalResponses [ 0 ] . response . status === 200 ) {
28+ if ( proposalResponses && proposalResponses [ 0 ] && proposalResponses [ 0 ] . response && proposalResponses [ 0 ] . response . status === 200 ) {
2929 console . log ( 'Successfully obtained transaction endorsement.' + JSON . stringify ( proposalResponses ) ) ;
3030 if ( ws ) ws . send ( JSON . stringify ( { msg : 'tx_step' , state : 'ordering' } ) ) ;
3131 return webUser . sendTransaction ( proposalResponses , proposal ) ;
@@ -158,13 +158,13 @@ module.exports = function (chain, chaincode_id, logger) {
158158 function ( results ) {
159159 var proposalResponses = results [ 0 ] ;
160160 var proposal = results [ 1 ] ;
161- if ( proposalResponses [ 0 ] && proposalResponses [ 0 ] . response && proposalResponses [ 0 ] . response . status === 200 ) {
161+ if ( proposalResponses && proposalResponses [ 0 ] && proposalResponses [ 0 ] . response && proposalResponses [ 0 ] . response . status === 200 ) {
162162 console . log ( 'Successfully obtained transaction endorsement.' + JSON . stringify ( proposalResponses ) ) ;
163163 if ( ws ) ws . send ( JSON . stringify ( { msg : 'tx_step' , state : 'ordering' } ) ) ;
164164 return webUser . sendTransaction ( proposalResponses , proposal ) ;
165165 }
166166 else {
167- console . log ( 'Failed to obtain transaction endorsement. Error msg: ' , proposalResponses [ 0 ] ) ;
167+ console . log ( 'Failed to obtain transaction endorsement' , proposalResponses ) ;
168168 if ( ws ) ws . send ( JSON . stringify ( { msg : 'tx_step' , state : 'endorsing_failed' } ) ) ;
169169 throw common . format_error_msg ( proposalResponses [ 0 ] ) ;
170170 }
@@ -218,13 +218,14 @@ module.exports = function (chain, chaincode_id, logger) {
218218 function ( results ) {
219219 var proposalResponses = results [ 0 ] ;
220220 var proposal = results [ 1 ] ;
221- if ( proposalResponses [ 0 ] . response . status === 200 ) {
221+ if ( proposalResponses && proposalResponses [ 0 ] && proposalResponses [ 0 ] . response && proposalResponses [ 0 ] . response . status === 200 ) {
222222 console . log ( 'Successfully obtained transaction endorsement.' + JSON . stringify ( proposalResponses ) ) ;
223223 if ( ws ) ws . send ( JSON . stringify ( { msg : 'tx_step' , state : 'ordering' } ) ) ;
224224 return webUser . sendTransaction ( proposalResponses , proposal ) ;
225225 }
226226 else {
227- console . log ( 'Failed to obtain transaction endorsement. Error code: ' + proposalResponses [ 0 ] . response . status ) ;
227+ console . log ( 'Failed to obtain transaction endorsement' , proposalResponses ) ;
228+ if ( ws ) ws . send ( JSON . stringify ( { msg : 'tx_step' , state : 'endorsing_failed' } ) ) ;
228229 throw common . format_error_msg ( proposalResponses [ 0 ] ) ;
229230 }
230231 }
@@ -237,6 +238,7 @@ module.exports = function (chain, chaincode_id, logger) {
237238 }
238239 else {
239240 console . log ( 'Failed to order the endorsement of the transaction.' ) ;
241+ if ( ws ) ws . send ( JSON . stringify ( { msg : 'tx_step' , state : 'ordering_failed' } ) ) ;
240242 throw response ;
241243 }
242244 }
@@ -245,6 +247,7 @@ module.exports = function (chain, chaincode_id, logger) {
245247 console . log ( 'error in catch block' , typeof err , err ) ;
246248 var e = null ;
247249 if ( typeof err === 'string' ) { //only pass these errors until we fix it
250+ if ( err . indexOf ( 'cannot authorize' ) ) e = err ;
248251 if ( err . indexOf ( 'Marble does not exist' ) ) e = err ;
249252 if ( err . indexOf ( 'Incorrect number of arguments' ) ) e = err ;
250253 if ( err . indexOf ( 'Owner does not exist' ) ) e = err ;
0 commit comments