MeetCode
Home
Doubts
Why is my C function not returning the β¦
Solved
1
49
Ask Doubt
View All Doubts
Solvers Leaderboard
Tutorials
Quiz
All Tests
Leaderboard
My Tasks
User Login
Dark
Enable Notifications
Toggle navigation
Pretty Print Errors
NodeJS
Medium
4 views
Back to Questions
View Answer
0
Previous
Basic CLI Calculator
Medium
P
Next
Color Output Without Library
Hard
N
Problem Description
Catch an error and print message plus stack first line.
Input Format
No input.
Output Format
Print two lines.
Constraints
Donβt dump full stack.
Official Solution
function firstStackLine(stack) { const lines = String(stack || '').split('\ ').map((x) => x.trim()).filter(Boolean); return lines[1] || ''; } try { throw new Error('meetcode crash'); } catch (e) { console.log('Error: ' + e.message); console.log(firstStackLine(e.stack)); }
Please
login
to submit solutions and comments.
Solutions (0)
No solutions submitted yet. Be the first!
Discussion (0)
No comments yet. Start the discussion!
Prev
Next
Fullscreen Editor
0 lines β’ 0 chars
Esc close β’ Tab indent
No comments yet. Start the discussion!