Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
0e7e1e5f
Commit
0e7e1e5f
authored
Apr 13, 2020
by
ioedeveloper
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added error code and handlers
parent
56a09c94
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
38 deletions
+40
-38
fileManager.js
src/app/files/fileManager.js
+36
-35
compilerContainer.js
src/app/tabs/compileTab/compilerContainer.js
+1
-1
test-tab.js
src/app/tabs/test-tab.js
+2
-2
tooltip.js
src/app/ui/tooltip.js
+1
-0
No files found.
src/app/files/fileManager.js
View file @
0e7e1e5f
...
@@ -23,7 +23,7 @@ const profile = {
...
@@ -23,7 +23,7 @@ const profile = {
icon
:
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iMTc5MiIgaGVpZ2h0PSIxNzkyIiB2aWV3Qm94PSIwIDAgMTc5MiAxNzkyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGQ9Ik0xNjk2IDM4NHE0MCAwIDY4IDI4dDI4IDY4djEyMTZxMCA0MC0yOCA2OHQtNjggMjhoLTk2MHEtNDAgMC02OC0yOHQtMjgtNjh2LTI4OGgtNTQ0cS00MCAwLTY4LTI4dC0yOC02OHYtNjcycTAtNDAgMjAtODh0NDgtNzZsNDA4LTQwOHEy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Y4IDI4aC00MTZ2NjQwaDg5NnoiLz48L3N2Zz4='
,
permission
:
true
,
permission
:
true
,
version
:
packageJson
.
version
,
version
:
packageJson
.
version
,
methods
:
[
'
getCurrentFile'
,
'getFile'
,
'
setFile'
,
'switchFile'
,
'file'
,
'exists'
,
'open'
,
'writeFile'
,
'readFile'
,
'copyFile'
,
'unlink'
,
'rename'
,
'readdir'
,
'rmdir'
],
methods
:
[
'setFile'
,
'switchFile'
,
'file'
,
'exists'
,
'open'
,
'writeFile'
,
'readFile'
,
'copyFile'
,
'unlink'
,
'rename'
,
'readdir'
,
'rmdir'
],
kind
:
'file-system'
kind
:
'file-system'
}
}
...
@@ -60,7 +60,7 @@ class FileManager extends Plugin {
...
@@ -60,7 +60,7 @@ class FileManager extends Plugin {
*/
*/
_handleIsFile
(
path
,
message
)
{
_handleIsFile
(
path
,
message
)
{
if
(
!
this
.
isFile
(
path
))
{
if
(
!
this
.
isFile
(
path
))
{
this
.
_handleError
({
message
:
`Path
${
path
}
is not a file:
${
message
}
.`
})
this
.
_handleError
({
code
:
'EISDIR'
,
message
})
}
}
}
}
...
@@ -71,7 +71,7 @@ class FileManager extends Plugin {
...
@@ -71,7 +71,7 @@ class FileManager extends Plugin {
*/
*/
_handleIsDir
(
path
,
message
)
{
_handleIsDir
(
path
,
message
)
{
if
(
this
.
isFile
(
path
))
{
if
(
this
.
isFile
(
path
))
{
throw
new
Error
(
`Path
${
path
}
is not a directory:
${
message
}
.`
)
throw
new
Error
(
{
code
:
'ENOTDIR'
,
message
}
)
}
}
}
}
...
@@ -80,24 +80,26 @@ class FileManager extends Plugin {
...
@@ -80,24 +80,26 @@ class FileManager extends Plugin {
* @param {object} error error { code, message }
* @param {object} error error { code, message }
*/
*/
_handleError
(
error
)
{
_handleError
(
error
)
{
if
(
error
.
message
)
{
const
message
=
error
.
message
?
`:
${
error
.
message
}
`
:
''
throw
new
Error
(
message
)
}
if
(
error
.
code
===
'ENOENT'
)
{
if
(
error
.
code
===
'ENOENT'
)
{
throw
new
Error
(
'No such file or directory'
)
throw
new
Error
(
'No such file or directory'
+
message
)
}
}
if
(
error
.
code
===
'EISDIR'
)
{
if
(
error
.
code
===
'EISDIR'
)
{
throw
new
Error
(
'Invalid operation on a directory'
)
throw
new
Error
(
'Path is a directory'
+
message
)
}
if
(
error
.
code
===
'ENOTDIR'
)
{
throw
new
Error
(
'Path is not on a directory'
+
message
)
}
}
if
(
error
.
code
===
'EEXIST'
)
{
if
(
error
.
code
===
'EEXIST'
)
{
throw
new
Error
(
'File already exists'
)
throw
new
Error
(
'File already exists'
+
message
)
}
}
if
(
error
.
code
===
'EPERM'
||
error
.
code
===
'EACCESS'
)
{
if
(
error
.
code
===
'EPERM'
||
error
.
code
===
'EACCESS'
)
{
throw
new
Error
(
'Permission denied'
)
throw
new
Error
(
'Permission denied'
+
message
)
}
}
return
error
return
error
...
@@ -105,7 +107,10 @@ class FileManager extends Plugin {
...
@@ -105,7 +107,10 @@ class FileManager extends Plugin {
/** The current opened file */
/** The current opened file */
file
()
{
file
()
{
return
this
.
currentFile
()
const
file
=
this
.
currentFile
()
if
(
!
file
)
this
.
_handleError
({
code
:
'ENOENT'
,
message
:
'No file selected'
})
return
file
}
}
/**
/**
...
@@ -125,7 +130,9 @@ class FileManager extends Plugin {
...
@@ -125,7 +130,9 @@ class FileManager extends Plugin {
*/
*/
isFile
(
path
)
{
isFile
(
path
)
{
const
extension
=
path
.
split
(
'.'
).
pop
()
const
extension
=
path
.
split
(
'.'
).
pop
()
return
!!
extension
&&
extension
.
split
(
'/'
).
length
===
0
const
splitExtension
=
extension
.
split
(
'/'
)
return
!!
extension
&&
splitExtension
.
length
===
1
&&
splitExtension
[
0
]
===
extension
}
}
/**
/**
...
@@ -134,8 +141,8 @@ class FileManager extends Plugin {
...
@@ -134,8 +141,8 @@ class FileManager extends Plugin {
* @returns {void}
* @returns {void}
*/
*/
open
(
path
)
{
open
(
path
)
{
this
.
_handleExists
(
path
,
'Cannot open file'
)
this
.
_handleExists
(
path
,
`Cannot open file
${
path
}
`
)
this
.
_handleIsFile
(
path
,
'Cannot open file'
)
this
.
_handleIsFile
(
path
,
`Cannot open file
${
path
}
`
)
this
.
switchFile
(
path
)
this
.
switchFile
(
path
)
}
}
...
@@ -146,7 +153,7 @@ class FileManager extends Plugin {
...
@@ -146,7 +153,7 @@ class FileManager extends Plugin {
* @returns {void}
* @returns {void}
*/
*/
writeFile
(
path
,
data
)
{
writeFile
(
path
,
data
)
{
this
.
_handleIsFile
(
path
,
'Cannot write file'
)
this
.
_handleIsFile
(
path
,
`Cannot write file
${
path
}
`
)
this
.
setFile
(
path
,
data
)
this
.
setFile
(
path
,
data
)
}
}
...
@@ -156,8 +163,8 @@ class FileManager extends Plugin {
...
@@ -156,8 +163,8 @@ class FileManager extends Plugin {
* @returns {string} content of the file
* @returns {string} content of the file
*/
*/
readFile
(
path
)
{
readFile
(
path
)
{
this
.
_handleExists
(
path
,
'Cannot read file'
)
this
.
_handleExists
(
path
,
`Cannot read file
${
path
}
`
)
this
.
_handleIsFile
(
path
,
'Cannot read file'
)
this
.
_handleIsFile
(
path
,
`Cannot read file
${
path
}
`
)
this
.
getFile
(
path
)
this
.
getFile
(
path
)
}
}
...
@@ -168,9 +175,9 @@ class FileManager extends Plugin {
...
@@ -168,9 +175,9 @@ class FileManager extends Plugin {
* @returns {void}
* @returns {void}
*/
*/
copyFile
(
src
,
dest
)
{
copyFile
(
src
,
dest
)
{
this
.
_handleExists
(
src
,
'Cannot copy from it'
)
this
.
_handleExists
(
src
,
`Cannot copy from
${
src
}
`
)
this
.
_handleIsFile
(
src
,
'Cannot copy from it'
)
this
.
_handleIsFile
(
src
,
`Cannot copy from
${
src
}
`
)
this
.
_handleIsFile
(
dest
,
'Cannot paste content into it'
)
this
.
_handleIsFile
(
dest
,
`Cannot paste content into
${
dest
}
`
)
const
content
=
this
.
readFile
(
src
)
const
content
=
this
.
readFile
(
src
)
this
.
writeFile
(
dest
,
content
)
this
.
writeFile
(
dest
,
content
)
}
}
...
@@ -182,8 +189,8 @@ class FileManager extends Plugin {
...
@@ -182,8 +189,8 @@ class FileManager extends Plugin {
* @returns {void}
* @returns {void}
*/
*/
unlink
(
path
)
{
unlink
(
path
)
{
this
.
_handleExists
(
path
,
'Cannot remove file'
)
this
.
_handleExists
(
path
,
`Cannot remove file
${
path
}
`
)
this
.
_handleIsDir
(
path
,
'Cannot remove file'
)
this
.
_handleIsDir
(
path
,
`Cannot remove file
${
path
}
`
)
}
}
/**
/**
...
@@ -193,7 +200,7 @@ class FileManager extends Plugin {
...
@@ -193,7 +200,7 @@ class FileManager extends Plugin {
* @returns {void}
* @returns {void}
*/
*/
rename
(
oldPath
,
newPath
)
{
rename
(
oldPath
,
newPath
)
{
this
.
__handleExists
(
oldPath
,
'Cannot rename'
)
this
.
__handleExists
(
oldPath
,
`Cannot rename
${
oldPath
}
`
)
// todo: should we verify if newPath exists here ?
// todo: should we verify if newPath exists here ?
const
isFile
=
this
.
isFile
(
oldPath
)
const
isFile
=
this
.
isFile
(
oldPath
)
this
.
fileRenamedEvent
(
oldPath
,
newPath
,
!
isFile
)
this
.
fileRenamedEvent
(
oldPath
,
newPath
,
!
isFile
)
...
@@ -206,7 +213,7 @@ class FileManager extends Plugin {
...
@@ -206,7 +213,7 @@ class FileManager extends Plugin {
*/
*/
mkdir
(
path
)
{
mkdir
(
path
)
{
if
(
this
.
exists
(
path
))
{
if
(
this
.
exists
(
path
))
{
th
row
new
Error
(
`Path
${
path
}
already exists: Cannot create a directory`
)
th
is
.
_handleError
({
code
:
'EEXIST'
,
message
:
`Cannot create directory
${
path
}
`
}
)
}
}
// To implement
// To implement
}
}
...
@@ -237,8 +244,8 @@ class FileManager extends Plugin {
...
@@ -237,8 +244,8 @@ class FileManager extends Plugin {
* @returns {void}
* @returns {void}
*/
*/
rmdir
(
path
)
{
rmdir
(
path
)
{
this
.
_handleExists
(
path
,
'Cannot remove directory'
)
this
.
_handleExists
(
path
,
`Cannot remove directory
${
path
}
`
)
this
.
_handleIsDir
(
path
,
'Cannot remove directory'
)
this
.
_handleIsDir
(
path
,
`Cannot remove directory
${
path
}
`
)
// To implement
// To implement
}
}
...
@@ -329,15 +336,10 @@ class FileManager extends Plugin {
...
@@ -329,15 +336,10 @@ class FileManager extends Plugin {
return
path
?
path
[
1
]
:
null
return
path
?
path
[
1
]
:
null
}
}
getCurrentFile
()
{
const
path
=
this
.
currentFile
()
if
(
!
path
)
throw
new
Error
(
'No file selected'
)
return
path
}
getFile
(
path
)
{
getFile
(
path
)
{
const
provider
=
this
.
fileProviderOf
(
path
)
const
provider
=
this
.
fileProviderOf
(
path
)
if
(
!
provider
)
throw
new
Error
(
`
${
path
}
not available`
)
if
(
!
provider
)
this
.
_handleError
({
code
:
'ENOENT'
,
message
:
`
${
path
}
not available`
})
// TODO: change provider to Promise
// TODO: change provider to Promise
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
currentFile
()
===
path
)
return
resolve
(
this
.
editor
.
currentContent
())
if
(
this
.
currentFile
()
===
path
)
return
resolve
(
this
.
editor
.
currentContent
())
...
@@ -372,7 +374,7 @@ class FileManager extends Plugin {
...
@@ -372,7 +374,7 @@ class FileManager extends Plugin {
_setFileInternal
(
path
,
content
)
{
_setFileInternal
(
path
,
content
)
{
const
provider
=
this
.
fileProviderOf
(
path
)
const
provider
=
this
.
fileProviderOf
(
path
)
if
(
!
provider
)
th
row
new
Error
(
`
${
path
}
not availble`
)
if
(
!
provider
)
th
is
.
_handleError
({
code
:
'ENOENT'
,
message
:
`
${
path
}
not available`
}
)
// TODO : Add permission
// TODO : Add permission
// TODO : Change Provider to Promise
// TODO : Change Provider to Promise
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
...
@@ -389,7 +391,6 @@ class FileManager extends Plugin {
...
@@ -389,7 +391,6 @@ class FileManager extends Plugin {
if
(
fileProvider
)
{
if
(
fileProvider
)
{
helper
.
createNonClashingNameWithPrefix
(
path
,
fileProvider
,
''
,
(
error
,
copyName
)
=>
{
helper
.
createNonClashingNameWithPrefix
(
path
,
fileProvider
,
''
,
(
error
,
copyName
)
=>
{
if
(
error
)
{
if
(
error
)
{
console
.
log
(
'createNonClashingNameWithPrefix'
,
error
)
copyName
=
path
+
'.'
+
this
.
currentRequest
.
from
copyName
=
path
+
'.'
+
this
.
currentRequest
.
from
}
}
this
.
_setFileInternal
(
copyName
,
content
)
this
.
_setFileInternal
(
copyName
,
content
)
...
...
src/app/tabs/compileTab/compilerContainer.js
View file @
0e7e1e5f
...
@@ -141,7 +141,7 @@ class CompilerContainer {
...
@@ -141,7 +141,7 @@ class CompilerContainer {
// Load solc compiler version according to pragma in contract file
// Load solc compiler version according to pragma in contract file
_setCompilerVersionFromPragma
(
filename
)
{
_setCompilerVersionFromPragma
(
filename
)
{
if
(
!
this
.
data
.
allversions
)
return
if
(
!
this
.
data
.
allversions
)
return
this
.
compileTabLogic
.
fileManager
.
get
File
(
filename
).
then
(
data
=>
{
this
.
compileTabLogic
.
fileManager
.
read
File
(
filename
).
then
(
data
=>
{
const
pragmaArr
=
data
.
match
(
/
(
pragma solidity
(
.+
?)
;
)
/g
)
const
pragmaArr
=
data
.
match
(
/
(
pragma solidity
(
.+
?)
;
)
/g
)
if
(
pragmaArr
&&
pragmaArr
.
length
===
1
)
{
if
(
pragmaArr
&&
pragmaArr
.
length
===
1
)
{
const
pragmaStr
=
pragmaArr
[
0
].
replace
(
'pragma solidity'
,
''
).
trim
()
const
pragmaStr
=
pragmaArr
[
0
].
replace
(
'pragma solidity'
,
''
).
trim
()
...
...
src/app/tabs/test-tab.js
View file @
0e7e1e5f
...
@@ -289,7 +289,7 @@ module.exports = class TestTab extends ViewPlugin {
...
@@ -289,7 +289,7 @@ module.exports = class TestTab extends ViewPlugin {
}
}
async
testFromPath
(
path
)
{
async
testFromPath
(
path
)
{
const
fileContent
=
await
this
.
fileManager
.
get
File
(
path
)
const
fileContent
=
await
this
.
fileManager
.
read
File
(
path
)
return
this
.
testFromSource
(
fileContent
,
path
)
return
this
.
testFromSource
(
fileContent
,
path
)
}
}
...
@@ -323,7 +323,7 @@ module.exports = class TestTab extends ViewPlugin {
...
@@ -323,7 +323,7 @@ module.exports = class TestTab extends ViewPlugin {
return
return
}
}
this
.
resultStatistics
.
hidden
=
false
this
.
resultStatistics
.
hidden
=
false
this
.
fileManager
.
get
File
(
testFilePath
).
then
((
content
)
=>
{
this
.
fileManager
.
read
File
(
testFilePath
).
then
((
content
)
=>
{
const
runningTest
=
{}
const
runningTest
=
{}
runningTest
[
testFilePath
]
=
{
content
}
runningTest
[
testFilePath
]
=
{
content
}
const
{
currentVersion
,
evmVersion
,
optimize
}
=
this
.
compileTab
.
getCurrentCompilerConfig
()
const
{
currentVersion
,
evmVersion
,
optimize
}
=
this
.
compileTab
.
getCurrentCompilerConfig
()
...
...
src/app/ui/tooltip.js
View file @
0e7e1e5f
...
@@ -34,6 +34,7 @@ class Toaster {
...
@@ -34,6 +34,7 @@ class Toaster {
}
}
render
(
tooltipText
,
actionElement
,
opts
)
{
render
(
tooltipText
,
actionElement
,
opts
)
{
console
.
log
(
'tooltipText: '
,
tooltipText
)
opts
=
defaultOptions
(
opts
)
opts
=
defaultOptions
(
opts
)
let
canShorten
=
true
let
canShorten
=
true
if
(
tooltipText
instanceof
Element
)
{
if
(
tooltipText
instanceof
Element
)
{
...
...
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