Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
pub
frama-c
Commits
15a855aa
Commit
15a855aa
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome] TS port for errors
parent
a75b4445
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/src/dome/src/renderer/errors.tsx
+84
-0
84 additions, 0 deletions
ivette/src/dome/src/renderer/errors.tsx
ivette/src/frama-c/LabViews.tsx
+2
-2
2 additions, 2 deletions
ivette/src/frama-c/LabViews.tsx
with
86 additions
and
2 deletions
ivette/src/dome/src/renderer/errors.
js
→
ivette/src/dome/src/renderer/errors.
tsx
+
84
−
0
View file @
15a855aa
...
@@ -7,47 +7,53 @@
...
@@ -7,47 +7,53 @@
@module dome/errors
@module dome/errors
*/
*/
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
{
Label
}
from
'
dome/controls/labels
'
;
import
{
Label
}
from
'
dome/controls/labels
'
;
import
{
Button
}
from
'
dome/controls/buttons
'
;
import
{
Button
}
from
'
dome/controls/buttons
'
;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Error Boundaries
// --- Error Boundaries
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
/**
/**
@summary React Error Boundaries.
Alternative renderer in case of error.
@property {string} [label] - Default error box label
@param reload - callback for re-rendering the faulty component
@property {function} [onError] - Alternative renderer
*/
@description
export
interface
renderError
{
Install an error boundary. In case of error, the default
(
error
:
any
,
info
:
any
,
reload
:
()
=>
void
):
JSX
.
Element
;
rendering is a warning button that output on console the
}
catched error.
export
interface
CatchProps
{
/** Name of the error boundary. */
label
?:
string
;
/** Alternative renderer callback in case of errors. */
onError
?:
JSX
.
Element
|
renderError
;
}
An alternative rendering can be supplied
interface
CatchState
{
with `onError:(error,info) => React.Element`.
error
?:
any
;
info
?:
any
;
}
/**
React Error Boundaries.
*/
*/
export
class
Catch
extends
React
.
Component
export
class
Catch
extends
React
.
Component
<
CatchProps
,
CatchState
,
{}
>
{
{
constructor
(
props
)
{
constructor
(
props
:
CatchProps
)
{
super
(
props
);
super
(
props
);
this
.
state
=
{
};
this
.
state
=
{};
this
.
logerr
=
this
.
logerr
.
bind
(
this
);
this
.
logerr
=
this
.
logerr
.
bind
(
this
);
this
.
reload
=
this
.
reload
.
bind
(
this
);
this
.
reload
=
this
.
reload
.
bind
(
this
);
}
}
dumpError
(
error
,
info
)
{
componentDidCatch
(
error
:
any
,
info
:
any
)
{
}
componentDidCatch
(
error
,
info
)
{
this
.
setState
({
error
,
info
});
this
.
setState
({
error
,
info
});
}
}
logerr
()
{
logerr
()
{
const
{
error
,
info
}
=
this
.
state
;
const
{
error
,
info
}
=
this
.
state
;
console
.
error
(
'
[dome] Catched error:
'
,
error
,
info
);
console
.
error
(
'
[dome] Catched error:
'
,
error
,
info
);
}
}
reload
()
{
reload
()
{
...
@@ -55,23 +61,23 @@ export class Catch extends React.Component
...
@@ -55,23 +61,23 @@ export class Catch extends React.Component
}
}
render
()
{
render
()
{
const
{
error
,
info
}
=
this
.
state
;
const
{
error
,
info
}
=
this
.
state
;
if
(
error
)
{
if
(
error
)
{
const
{
onError
,
label
=
'
Error
'
}
=
this
.
props
;
const
{
onError
,
label
=
'
Error
'
}
=
this
.
props
;
if
(
typeof
(
onError
)
===
'
function
'
)
if
(
typeof
(
onError
)
===
'
function
'
)
return
onError
(
error
,
info
,
this
.
reload
);
return
onError
(
error
,
info
,
this
.
reload
);
else
else
return
(
return
(
<
div
>
<
div
>
<
Button
icon
=
'WARNING'
kind
=
'warning'
<
Button
icon
=
'WARNING'
kind
=
'warning'
title
=
{
error
}
title
=
{
error
}
onClick
=
{
this
.
logerr
}
/
>
onClick
=
{
this
.
logerr
}
/>
<
Button
icon
=
'RELOAD'
onClick
=
{
this
.
reload
}
/>
<
Button
icon
=
'RELOAD'
onClick
=
{
this
.
reload
}
/>
<
Label
>
{
label
}
</
Label
>
<
Label
>
{
label
}
</
Label
>
</
div
>
</
div
>
);
);
}
}
return
this
.
props
.
children
||
null
;
return
this
.
props
.
children
||
null
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
ivette/src/frama-c/LabViews.tsx
+
2
−
2
View file @
15a855aa
...
@@ -329,7 +329,7 @@ const makeGridItem = (customize: any, onClose: any) => (comp: any) => {
...
@@ -329,7 +329,7 @@ const makeGridItem = (customize: any, onClose: any) => (comp: any) => {
<
Vfill
className
=
"labview-content"
>
<
Vfill
className
=
"labview-content"
>
<
Hbox
className
=
"labview-titlebar"
>
<
Hbox
className
=
"labview-titlebar"
>
<
Hfill
>
<
Hfill
>
<
Catch
title
=
{
id
}
>
<
Catch
label
=
{
id
}
>
<
RenderItem
id
=
{
`labview.title.
${
id
}
`
}
>
<
RenderItem
id
=
{
`labview.title.
${
id
}
`
}
>
<
Label
className
=
"labview-handle"
label
=
{
label
}
title
=
{
title
}
/>
<
Label
className
=
"labview-handle"
label
=
{
label
}
title
=
{
title
}
/>
</
RenderItem
>
</
RenderItem
>
...
@@ -338,7 +338,7 @@ const makeGridItem = (customize: any, onClose: any) => (comp: any) => {
...
@@ -338,7 +338,7 @@ const makeGridItem = (customize: any, onClose: any) => (comp: any) => {
{
CLOSING
}
{
CLOSING
}
</
Hbox
>
</
Hbox
>
<
TitleContext
.
Provider
value
=
{
{
id
,
label
,
title
}
}
>
<
TitleContext
.
Provider
value
=
{
{
id
,
label
,
title
}
}
>
<
Catch
title
=
{
id
}
>
{
children
}
</
Catch
>
<
Catch
label
=
{
id
}
>
{
children
}
</
Catch
>
</
TitleContext
.
Provider
>
</
TitleContext
.
Provider
>
</
Vfill
>
</
Vfill
>
</
Grids
.
GridItem
>
</
Grids
.
GridItem
>
...
...
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