File tree Expand file tree Collapse file tree 4 files changed +22
-23
lines changed
packages/ketcher-react/src/script/ui Expand file tree Collapse file tree 4 files changed +22
-23
lines changed Original file line number Diff line number Diff line change 14
14
* limitations under the License.
15
15
***************************************************************************/
16
16
17
- import { ChemicalMimeType , KetcherLogger , KetSerializer } from 'ketcher-core' ;
17
+ import {
18
+ ChemicalMimeType ,
19
+ KetcherLogger ,
20
+ KetSerializer ,
21
+ ketcherProvider ,
22
+ } from 'ketcher-core' ;
18
23
import { appUpdate , setStruct } from '../options' ;
19
24
import { omit , without } from 'lodash/fp' ;
20
25
21
26
import { checkErrors } from '../modal/form' ;
22
27
import { indigoVerification } from '../request' ;
23
28
import { load } from '../shared' ;
29
+ import { GLOBAL_ERROR_HANDLER } from 'src/constants' ;
24
30
25
31
export function checkServer ( ) {
26
32
return ( dispatch , getState ) => {
@@ -112,6 +118,7 @@ export function analyse() {
112
118
} ) ;
113
119
const { editor, server, options } = getState ( ) ;
114
120
const serverSettings = options . getServerSettings ( ) ;
121
+ const ketcher = ketcherProvider . getKetcher ( ) ;
115
122
serverSettings . data = {
116
123
properties : [
117
124
'molecular-weight' ,
@@ -132,7 +139,9 @@ export function analyse() {
132
139
. catch ( ( e ) => {
133
140
KetcherLogger . error ( 'index.js::analyse' , e ) ;
134
141
editor . errorHandler ( e ) ;
135
- throw e ;
142
+ if ( ketcher && ketcher . eventBus ) {
143
+ ketcher . eventBus . emit ( GLOBAL_ERROR_HANDLER , e ) ;
144
+ }
136
145
} ) ;
137
146
} ;
138
147
}
Original file line number Diff line number Diff line change @@ -26,11 +26,13 @@ import {
26
26
Editor ,
27
27
KetcherLogger ,
28
28
SettingsManager ,
29
+ ketcherProvider ,
29
30
} from 'ketcher-core' ;
30
31
31
32
import { supportedSGroupTypes } from './constants' ;
32
33
import { setAnalyzingFile } from './request' ;
33
34
import tools from '../action/tools' ;
35
+ import { GLOBAL_ERROR_HANDLER } from 'src/constants' ;
34
36
35
37
export function onAction ( action ) {
36
38
if ( action && action . dialog ) {
@@ -101,6 +103,7 @@ export function load(struct: Struct, options?) {
101
103
const editor = state . editor as Editor ;
102
104
const server = state . server ;
103
105
const errorHandler = editor . errorHandler ;
106
+ const ketcher = ketcherProvider . getKetcher ( ) ;
104
107
options = options || { } ;
105
108
let { isPaste, ...otherOptions } = options ;
106
109
otherOptions = {
@@ -184,7 +187,9 @@ export function load(struct: Struct, options?) {
184
187
KetcherLogger . error ( 'shared.ts::load' , e ) ;
185
188
dispatch ( setAnalyzingFile ( false ) ) ;
186
189
e && errorHandler && errorHandler ( e . message ) ;
187
- throw e ;
190
+ if ( ketcher && ketcher . eventBus ) {
191
+ ketcher . eventBus . emit ( GLOBAL_ERROR_HANDLER , e . message ) ;
192
+ }
188
193
} finally {
189
194
notifyRequestCompleted ( ) ;
190
195
}
Original file line number Diff line number Diff line change @@ -22,8 +22,7 @@ import Recognize from '../../process/Recognize/Recognize';
22
22
import { fileOpener } from '../../../../../utils/' ;
23
23
import { DialogActionButton } from './components/DialogActionButton' ;
24
24
import { ViewSwitcher } from './components/ViewSwitcher' ;
25
- import { getFormatMimeTypeByFileName , ketcherProvider } from 'ketcher-core' ;
26
- import { GLOBAL_ERROR_HANDLER } from 'src/constants' ;
25
+ import { getFormatMimeTypeByFileName } from 'ketcher-core' ;
27
26
import { useDispatch } from 'react-redux' ;
28
27
import { load } from 'src/script/ui/state/shared' ;
29
28
@@ -117,17 +116,10 @@ const Open: FC<Props> = (props) => {
117
116
// @TODO after Recognize is refactored this will not be necessary
118
117
// currently not destructuring onOk with other props so we can pass it with ...rest to Recognize below
119
118
120
- const ketcher = ketcherProvider . getKetcher ( ) ;
121
119
const onOk = async ( res ) => {
122
- try {
123
- await dispatch (
124
- load ( res . structStr , { badHeaderRecover : true , fragment : res . fragment } ) ,
125
- ) ;
126
- } catch ( error : any ) {
127
- if ( ketcher && ketcher . eventBus ) {
128
- ketcher . eventBus . emit ( GLOBAL_ERROR_HANDLER , error . message ) ;
129
- }
130
- }
120
+ await dispatch (
121
+ load ( res . structStr , { badHeaderRecover : true , fragment : res . fragment } ) ,
122
+ ) ;
131
123
} ;
132
124
133
125
const copyHandler = ( ) => {
Original file line number Diff line number Diff line change @@ -153,14 +153,7 @@ const mapStateToProps = (state) => ({
153
153
} ) ;
154
154
155
155
const mapDispatchToProps = ( dispatch ) => ( {
156
- onAnalyse : ( ) => {
157
- return dispatch ( analyse ( ) ) . catch ( ( error ) => {
158
- const ketcher = ketcherProvider . getKetcher ( ) ;
159
- if ( ketcher && ketcher . eventBus ) {
160
- ketcher . eventBus . emit ( GLOBAL_ERROR_HANDLER , error ) ;
161
- }
162
- } ) ;
163
- } ,
156
+ onAnalyse : ( ) => dispatch ( analyse ( ) ) ,
164
157
onChangeRound : ( roundName , val ) => dispatch ( changeRound ( roundName , val ) ) ,
165
158
} ) ;
166
159
You can’t perform that action at this time.
0 commit comments