Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
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
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
code
pugs
Merge requests
!168
Simplify backtrace output
Code
Review changes
Check out branch
Download
Patches
Plain diff
Expand sidebar
Merged
Simplify backtrace output
feature/error-handling
into
develop
Overview
0
Commits
6
Pipelines
0
Changes
61
Merged
Simplify backtrace output
Stéphane Del Pino
requested to merge
feature/error-handling
into
develop
Jun 1, 2023
Overview
0
Commits
6
Pipelines
0
Changes
61
This makes backtrace readable
0
0
Merge request reports
Compare
develop
develop (base)
and
latest version
latest version
71d2f3a5
6 commits,
Jun 1, 2023
61 files
+
701
−
76
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
61
src/language/ast/ASTBacktrace.cpp
0 → 100644
+
63
−
0
View file @ 71d2f3a5
Edit in single-file editor
Open in Web IDE
#include
<language/ast/ASTBacktrace.hpp>
#include
<language/ast/ASTNode.hpp>
ASTBacktrace
*
ASTBacktrace
::
m_instance
=
nullptr
;
ASTBacktrace
::
ASTBacktrace
(
const
std
::
shared_ptr
<
TAO_PEGTL_NAMESPACE
::
file_input
<>>&
file_input
)
:
m_file_input
(
file_input
)
{}
std
::
string
ASTBacktrace
::
errorMessageAt
(
const
std
::
string
&
message
)
const
{
auto
&
stack
=
ASTBacktrace
::
getInstance
().
m_stack
;
std
::
ostringstream
error_msg
;
auto
p
=
stack
[
stack
.
size
()
-
1
]
->
begin
();
error_msg
<<
rang
::
style
::
bold
<<
p
.
source
<<
':'
<<
p
.
line
<<
':'
<<
p
.
column
<<
": "
<<
rang
::
style
::
reset
<<
message
<<
rang
::
fg
::
reset
<<
'\n'
;
if
(
m_file_input
.
use_count
()
>
0
)
{
error_msg
<<
m_file_input
->
line_at
(
p
)
<<
'\n'
<<
std
::
string
(
p
.
column
-
1
,
' '
)
<<
rang
::
fgB
::
yellow
<<
'^'
<<
rang
::
fg
::
reset
<<
'\n'
;
}
return
error_msg
.
str
();
}
SourceLocation
ASTBacktrace
::
sourceLocation
()
const
{
auto
&
stack
=
ASTBacktrace
::
getInstance
().
m_stack
;
auto
p
=
stack
[
stack
.
size
()
-
1
]
->
begin
();
return
SourceLocation
(
p
.
source
,
p
.
line
,
p
.
column
);
}
void
ASTBacktrace
::
create
()
{
if
(
m_instance
==
nullptr
)
{
m_instance
=
new
ASTBacktrace
();
}
else
{
throw
UnexpectedError
(
"ASTBackTrace was already created!"
);
}
}
void
ASTBacktrace
::
create
(
const
std
::
shared_ptr
<
TAO_PEGTL_NAMESPACE
::
file_input
<>>&
file_input
)
{
if
(
m_instance
==
nullptr
)
{
m_instance
=
new
ASTBacktrace
(
file_input
);
}
else
{
throw
UnexpectedError
(
"ASTBackTrace was already created!"
);
}
}
void
ASTBacktrace
::
destroy
()
{
delete
m_instance
;
m_instance
=
nullptr
;
}
Loading