File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
packages/compass-data-modeling/src/services Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -34,24 +34,24 @@ export async function getDiagramContentsFromFile(
3434 const reader = new FileReader ( ) ;
3535 return new Promise ( ( resolve , reject ) => {
3636 reader . onload = ( event ) => {
37- const content = event . target ?. result ;
38- if ( typeof content !== 'string' ) {
39- return reject ( new Error ( 'Invalid file contents' ) ) ;
40- }
4137 try {
38+ const content = event . target ?. result ;
39+ if ( typeof content !== 'string' ) {
40+ throw new Error ( 'Invalid file contents' ) ;
41+ }
4242 const parsedContent = JSON . parse ( content ) ;
4343
4444 if (
4545 parsedContent . version !== kCurrentVersion ||
4646 parsedContent . type !== kFileTypeDescription
4747 ) {
48- return reject ( new Error ( 'Unsupported diagram file format' ) ) ;
48+ throw new Error ( 'Unsupported diagram file format' ) ;
4949 }
5050
5151 const { name, edits } = parsedContent ;
5252
5353 if ( ! name || ! edits || typeof edits !== 'string' ) {
54- return reject ( new Error ( 'Diagram file is missing required fields' ) ) ;
54+ throw new Error ( 'Diagram file is missing required fields' ) ;
5555 }
5656
5757 const parsedEdits = JSON . parse (
You can’t perform that action at this time.
0 commit comments