Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6683241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:47:53+00:00 2026-05-26T04:47:53+00:00

Exceptions are used throughout the component I’m working in for API error handling: catch

  • 0

Exceptions are used throughout the component I’m working in for API error handling:

catch (Exception ex)
{
    // ex.ToString() below may be something like "database is locked"
    string error = string.Format(
        "Error when trying to create a playlist: {0}", ex.ToString());
    throw new Exception(error);
}

Basically a lower-level component will throw an Exception with detailed specifics of the error, and this will be caught at a higher-level with a more generic, user-friendly error message.

When my client application processes this application, it calls ex.ToString() to get the complete error string, but this also includes the call stack.

Error: exceptions.RuntimeError: Error when trying to create a playlist: 
System.Exception: database is locked
at <very large call stack here>

Is there an easy way to prevent the last section (i.e. at <very large call stack here>) from appearing in the error message, without having the parse the string? This is being returned to the user and I want the error to be user-focused not application-focused.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:47:54+00:00Added an answer on May 26, 2026 at 4:47 am

    Try using Exception.Message instead of Exception.ToString:

    string message = string.Format(
        "Error when trying to create a playlist: {0}", ex.Message);
    throw new YourException(message, ex);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know from wikipedia for example that exception handling is used in an application
I have a question about error/exception handling on the iPhone. I've read the documentation
I am writing a web app where exceptions are used to handle error cases.
My dll is used by a module which dirtily catch all exceptions and just
Constructor for PHP's exception has third parameter, documentation says: $previous: The previous exception used
How have you used the Exception.Data property in C# projects that you've worked on?
currently I used SetUnhandledExceptionFilter() to provide callback to get information when an unhandled exception
Ruby has two different exceptions mechanisms: Throw/Catch and Raise/Rescue. Why do we have two?
Should I catch exceptions for logging purposes? public foo(..) { try { ... }
I'm working on a Python library used by third-party developers to write extensions for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.