Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ascendbatch2025
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Bhargavi Ghanta
ascendbatch2025
Commits
82237d21
Commit
82237d21
authored
Jun 11, 2025
by
Bhargavi Ghanta
Browse files
Options
Browse Files
Download
Plain Diff
Resolve merge conflicts between local and remote
parents
787f8429
1954dd75
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
0 deletions
+61
-0
modules.xml
.idea/modules.xml
+4
-0
GlobalExceptionHandler.iml
GlobalExceptionHandler.iml
+11
-0
error.log
error.log
+6
-0
GlobalExceptionLogger.java
src/GlobalExceptionLogger.java
+40
-0
No files found.
.idea/modules.xml
View file @
82237d21
...
...
@@ -2,7 +2,11 @@
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<<<<<<
< HEAD
<module
fileurl=
"file://$PROJECT_DIR$/RetryUtility.iml"
filepath=
"$PROJECT_DIR$/RetryUtility.iml"
/>
=======
<module
fileurl=
"file://$PROJECT_DIR$/GlobalExceptionHandler.iml"
filepath=
"$PROJECT_DIR$/GlobalExceptionHandler.iml"
/>
>>>>>>> 1954dd751dcf534a5ca8daa53b9ea31178d381eb
</modules>
</component>
</project>
\ No newline at end of file
GlobalExceptionHandler.iml
0 → 100644
View file @
82237d21
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src"
isTestSource=
"false"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
\ No newline at end of file
error.log
0 → 100644
View file @
82237d21
----- Exception Occurred -----
Thread: main
Exception: java.lang.ArithmeticException: / by zero
at GlobalExceptionLogger.divide(GlobalExceptionLogger.java:23)
at GlobalExceptionLogger.main(GlobalExceptionLogger.java:16)
src/GlobalExceptionLogger.java
0 → 100644
View file @
82237d21
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
public
class
GlobalExceptionLogger
{
public
static
void
main
(
String
[]
args
)
{
// Set up global exception handler
Thread
.
setDefaultUncaughtExceptionHandler
((
thread
,
throwable
)
->
{
logException
(
throwable
);
});
// Sample code that throws an unhandled exception
System
.
out
.
println
(
"Program started."
);
int
result
=
divide
(
10
,
0
);
// This will cause ArithmeticException
System
.
out
.
println
(
"Result: "
+
result
);
}
// Method that may throw an exception
public
static
int
divide
(
int
a
,
int
b
)
{
return
a
/
b
;
// division by zero triggers an exception
}
// Method to log exceptions to a file
public
static
void
logException
(
Throwable
throwable
)
{
try
(
PrintWriter
writer
=
new
PrintWriter
(
new
FileWriter
(
"error.log"
,
true
)))
{
writer
.
println
(
"----- Exception Occurred -----"
);
writer
.
println
(
"Thread: "
+
Thread
.
currentThread
().
getName
());
writer
.
println
(
"Exception: "
+
throwable
);
for
(
StackTraceElement
element
:
throwable
.
getStackTrace
())
{
writer
.
println
(
"\tat "
+
element
);
}
writer
.
println
();
// Blank line for separation
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Failed to log exception: "
+
e
.
getMessage
());
}
}
}
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