Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
workerbee
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
workerbee
Commits
38b5d118
Verified
Commit
38b5d118
authored
1 year ago
by
Mateusz Tyszczak
Browse files
Options
Downloads
Patches
Plain Diff
Improve try catch blocks in queen bee class
parent
bab8a5f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/queen.ts
+48
-15
48 additions, 15 deletions
src/queen.ts
with
48 additions
and
15 deletions
src/queen.ts
+
48
−
15
View file @
38b5d118
...
...
@@ -15,14 +15,24 @@ export class QueenBee {
return
{
subscribe
:
(
observer
:
Partial
<
Observer
<
IBlockData
>>
):
Unsubscribable
=>
{
const
complete
=
():
void
=>
{
try
{
observer
.
complete
?.();
}
catch
(
error
)
{
try
{
observer
.
error
?.(
error
);
}
catch
{}
}
this
.
worker
.
off
(
"
block
"
,
listener
);
try
{
observer
.
complete
?.();
}
catch
(
error
)
{
observer
.
error
?.(
error
);
}
finally
{
this
.
worker
.
off
(
"
block
"
,
listener
);
}
};
const
listener
=
(
blockData
:
IBlockData
):
void
=>
{
const
confirm
=
():
void
=>
{
try
{
observer
.
next
?.(
blockData
);
}
catch
(
error
)
{
try
{
observer
.
error
?.(
error
);
}
catch
{}
}
complete
();
try
{
observer
.
next
?.(
blockData
);
}
catch
(
error
)
{
observer
.
error
?.(
error
);
}
finally
{
complete
();
}
};
if
(
typeof
idOrNumber
===
"
string
"
)
{
...
...
@@ -48,15 +58,25 @@ export class QueenBee {
let
timeoutId
:
undefined
|
NodeJS
.
Timeout
=
undefined
;
const
complete
=
():
void
=>
{
try
{
observer
.
complete
?.();
}
catch
(
error
)
{
try
{
observer
.
error
?.(
error
);
}
catch
{}
}
this
.
worker
.
off
(
"
transaction
"
,
listener
);
clearTimeout
(
timeoutId
);
try
{
observer
.
complete
?.();
}
catch
(
error
)
{
observer
.
error
?.(
error
);
}
finally
{
this
.
worker
.
off
(
"
transaction
"
,
listener
);
clearTimeout
(
timeoutId
);
}
};
const
listener
=
(
transactionData
:
ITransactionData
):
void
=>
{
const
confirm
=
():
void
=>
{
try
{
observer
.
next
?.(
transactionData
);
}
catch
(
error
)
{
try
{
observer
.
error
?.(
error
);
}
catch
{}
}
complete
();
try
{
observer
.
next
?.(
transactionData
);
}
catch
(
error
)
{
observer
.
error
?.(
error
);
}
finally
{
complete
();
}
};
if
(
txId
===
transactionData
.
id
)
...
...
@@ -66,9 +86,13 @@ export class QueenBee {
if
(
typeof
expireIn
===
"
number
"
)
timeoutId
=
setTimeout
(()
=>
{
try
{
observer
.
error
?.(
new
WorkerBeeError
(
"
Transaction expired
"
));
}
catch
{}
complete
();
try
{
observer
.
error
?.(
new
WorkerBeeError
(
"
Transaction expired
"
));
}
catch
(
error
)
{
observer
.
error
?.(
error
);
}
finally
{
complete
();
}
},
expireIn
);
return
{
...
...
@@ -84,15 +108,24 @@ export class QueenBee {
return
{
subscribe
:
(
observer
:
Partial
<
Observer
<
IOperationData
>>
):
Unsubscribable
=>
{
const
complete
=
():
void
=>
{
try
{
observer
.
complete
?.();
}
catch
(
error
)
{
try
{
observer
.
error
?.(
error
);
}
catch
{}
}
this
.
worker
.
off
(
"
transaction
"
,
listener
);
try
{
observer
.
complete
?.();
}
catch
(
error
)
{
observer
.
error
?.(
error
);
}
finally
{
this
.
worker
.
off
(
"
transaction
"
,
listener
);
}
};
const
visitor
=
new
AccountOperationVisitor
(
name
);
const
listener
=
(
transactionData
:
ITransactionData
):
void
=>
{
const
confirm
=
(
result
:
operation
):
void
=>
{
try
{
observer
.
next
?.({
op
:
result
,
transaction
:
transactionData
});
}
catch
(
error
)
{
try
{
observer
.
error
?.(
error
);
}
catch
{}
}
try
{
observer
.
next
?.({
op
:
result
,
transaction
:
transactionData
});
}
catch
(
error
)
{
observer
.
error
?.(
error
);
}
};
const
proto
=
this
.
worker
.
chain
!
.
TransactionBuilder
.
fromApi
(
transactionData
.
transaction
).
build
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment