Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
5a240c4b
Commit
5a240c4b
authored
Jun 06, 2017
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve error handling cube functions
parent
08a5ed40
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
20 deletions
+49
-20
cell/model/FormulaObjects/cubeFunctions.js
cell/model/FormulaObjects/cubeFunctions.js
+49
-20
No files found.
cell/model/FormulaObjects/cubeFunctions.js
View file @
5a240c4b
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
* @param {Window} window
* @param {Window} window
* @param {undefined} undefined
* @param {undefined} undefined
*/
*/
function
(
window
,
undefined
)
{
function
(
window
,
console
,
undefined
)
{
var
cBaseFunction
=
AscCommonExcel
.
cBaseFunction
;
var
cBaseFunction
=
AscCommonExcel
.
cBaseFunction
;
var
cFormulaFunctionGroup
=
AscCommonExcel
.
cFormulaFunctionGroup
,
var
cFormulaFunctionGroup
=
AscCommonExcel
.
cFormulaFunctionGroup
,
cElementType
=
AscCommonExcel
.
cElementType
,
cElementType
=
AscCommonExcel
.
cElementType
,
...
@@ -124,6 +124,9 @@
...
@@ -124,6 +124,9 @@
}
}
};
};
connection
=
connections
[
connection
];
connection
=
connections
[
connection
];
if
(
!
connection
)
{
throw
"
connection not exist
"
;
}
connection
=
JSON
.
parse
(
JSON
.
stringify
(
connection
));
connection
=
JSON
.
parse
(
JSON
.
stringify
(
connection
));
return
connection
;
return
connection
;
}
}
...
@@ -177,7 +180,7 @@
...
@@ -177,7 +180,7 @@
if
(
cell
)
{
if
(
cell
)
{
if
(
cell
.
oValue
.
type
===
cElementType
.
error
)
{
if
(
cell
.
oValue
.
type
===
cElementType
.
error
)
{
// debugger;
// debugger;
throw
"
refenced cell contain error
"
;
throw
"
refe
re
nced cell contain error
"
;
}
}
if
(
cell
.
formulaParsed
&&
cell
.
formulaParsed
.
value
)
{
if
(
cell
.
formulaParsed
&&
cell
.
formulaParsed
.
value
)
{
stringForge
(
cell
.
formulaParsed
.
value
);
stringForge
(
cell
.
formulaParsed
.
value
);
...
@@ -332,6 +335,23 @@
...
@@ -332,6 +335,23 @@
return
scheme
.
execute
.
promise
;
return
scheme
.
execute
.
promise
;
}
}
function
error_handler
(
current_cell_id
)
{
return
function
(
error
)
{
console
.
error
(
current_cell_id
,
error
);
var
ret
;
if
(
error
===
"
referenced cell contain error
"
)
{
ret
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
else
if
(
error
===
"
connection not exist
"
||
error
instanceof
Xmla
.
Exception
)
{
ret
=
new
cError
(
cErrorType
.
wrong_name
);
}
else
{
ret
=
new
cError
(
cErrorType
.
not_available
);
}
ret
.
ca
=
true
;
return
ret
;
};
}
/**
/**
* @constructor
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
* @extends {AscCommonExcel.cBaseFunction}
...
@@ -359,8 +379,9 @@
...
@@ -359,8 +379,9 @@
cCUBEMEMBER
.
prototype
.
constructor
=
cCUBEMEMBER
;
cCUBEMEMBER
.
prototype
.
constructor
=
cCUBEMEMBER
;
cCUBEMEMBER
.
prototype
.
argumentsMin
=
2
;
cCUBEMEMBER
.
prototype
.
argumentsMin
=
2
;
cCUBEMEMBER
.
prototype
.
argumentsMax
=
3
;
cCUBEMEMBER
.
prototype
.
argumentsMax
=
3
;
cCUBEMEMBER
.
prototype
.
CalculateLazy
=
function
(
queue
)
{
cCUBEMEMBER
.
prototype
.
CalculateLazy
=
function
(
queue
,
range
)
{
var
connection
,
var
connection
,
current_cell_id
=
range
.
getCells
()[
0
].
getId
(),
caption
;
caption
;
return
queue
return
queue
.
push
(
function
(
arg
)
{
.
push
(
function
(
arg
)
{
...
@@ -403,7 +424,8 @@
...
@@ -403,7 +424,8 @@
.
push
(
function
(
responses
)
{
.
push
(
function
(
responses
)
{
var
last_id
=
responses
.
length
-
1
,
var
last_id
=
responses
.
length
-
1
,
ret
,
ret
,
scheme
=
getScheme
(
connection
);
scheme
=
getScheme
(
connection
),
hierarchies
=
{};
if
(
!
caption
)
{
if
(
!
caption
)
{
caption
=
responses
[
last_id
].
getMemberCaption
();
caption
=
responses
[
last_id
].
getMemberCaption
();
}
}
...
@@ -411,21 +433,25 @@
...
@@ -411,21 +433,25 @@
ret
.
ca
=
true
;
ret
.
ca
=
true
;
ret
.
cube_value
=
responses
.
map
(
function
(
r
)
{
ret
.
cube_value
=
responses
.
map
(
function
(
r
)
{
var
uname
=
r
.
getMemberUniqueName
(),
var
uname
=
r
.
getMemberUniqueName
(),
member
=
scheme
.
members
[
uname
];
member
=
scheme
.
members
[
uname
],
hierarchy
=
r
.
getHierarchyUniqueName
();
if
(
hierarchies
.
hasOwnProperty
(
hierarchy
))
{
throw
"
The tuple is invalid because there is no intersection for the specified values.
"
;
}
else
{
hierarchies
[
hierarchy
]
=
1
;
}
if
(
!
member
)
{
if
(
!
member
)
{
scheme
.
members
[
uname
]
=
{
h
:
r
.
getHierarchyUniqueName
()
};
scheme
.
members
[
uname
]
=
{
h
:
hierarchy
};
}
}
return
uname
;
return
uname
;
});
});
return
ret
;
return
ret
;
})
})
.
push
(
undefined
,
function
()
{
.
push
(
undefined
,
error_handler
(
current_cell_id
));
return
new
cError
(
cErrorType
.
not_available
);
});
};
};
cCUBEMEMBER
.
prototype
.
getInfo
=
function
()
{
cCUBEMEMBER
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
args
:
"
(
x
)
"
name
:
this
.
name
,
args
:
"
(
connection, members, caption
)
"
};
};
};
};
...
@@ -509,13 +535,20 @@
...
@@ -509,13 +535,20 @@
return
parseArgs
(
arg
.
slice
(
1
))();
return
parseArgs
(
arg
.
slice
(
1
))();
})
})
.
push
(
function
(
m
)
{
.
push
(
function
(
m
)
{
var
hierarchies
=
{};
members
=
m
;
members
=
m
;
members
.
forEach
(
function
(
member
)
{
members
.
forEach
(
function
(
member
)
{
var
h
;
var
h
,
h
=
scheme
.
hierarchies
[
scheme
.
members
[
member
].
h
];
hierarchy
=
scheme
.
members
[
member
].
h
;
if
(
hierarchies
.
hasOwnProperty
(
hierarchy
))
{
throw
"
The tuple is invalid because there is no intersection for the specified values.
"
;
}
else
{
hierarchies
[
hierarchy
]
=
1
;
}
h
=
scheme
.
hierarchies
[
hierarchy
];
if
(
!
h
)
{
if
(
!
h
)
{
h
=
[];
h
=
[];
scheme
.
hierarchies
[
scheme
.
members
[
member
].
h
]
=
h
;
scheme
.
hierarchies
[
hierarchy
]
=
h
;
}
}
if
(
h
.
indexOf
(
member
)
===
-
1
)
{
if
(
h
.
indexOf
(
member
)
===
-
1
)
{
h
.
push
(
member
);
h
.
push
(
member
);
...
@@ -570,21 +603,17 @@
...
@@ -570,21 +603,17 @@
return
ret
;
return
ret
;
})
})
.
push
(
undefined
,
function
(
error
)
{
.
push
(
undefined
,
function
(
error
)
{
console
.
log
(
error
,
current_cell_id
);
// issue in one cell(cubevalue) not stop calculation in other
return
waiter
()
return
waiter
()
.
then
(
function
()
{
.
then
(
function
()
{
var
ret
=
new
cError
(
cErrorType
.
not_available
);
return
error_handler
(
current_cell_id
)(
error
);
ret
.
ca
=
true
;
return
ret
;
});
});
});
});
};
};
// cCUBEVALUE.prototype.Calculate = cCUBEVALUE.prototype.CalculateLazy
cCUBEVALUE
.
prototype
.
getInfo
=
function
()
{
cCUBEVALUE
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
name
:
this
.
name
,
args
:
"
( connection, member1, member2, .. )
"
name
:
this
.
name
,
args
:
"
( connection, member1, member2, .. )
"
};
};
};
};
})
})
(
window
);
(
window
,
console
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment