Files
openproject/lib/api/errors/safe_internal_error.rb
T
Jan Sandbrink 953ab1a6a8 Fix API::Errors::InternalError class
This class got broken during what seems to be a
drive-by style-improvement in fbe1215365. That change:

* made it incompatible with frozen strings as error messages
* broke the intended hiding of messages if they came from the
  wrong class

All of this went by unnoticed, because there were no specs
for the InternalError class.

Specs have now been added and the previous version of the code
mostly restored. Since there were some callers that always created the
exception with known safe error messages, I added a new class just for these
cases, because they were intended to "just show the message". So we can
keep using the original implementation for rescue_from handling.
2026-02-09 11:04:57 +01:00

42 lines
1.6 KiB
Ruby

# frozen_string_literal: true
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++
module API
module Errors
# A representation for internal server errors that applies no filtering of the error message.
# Only use this, if you know that the error message you are passing in is safe to be displayed to the user, as no
# filtering of error messages will happen.
class SafeInternalError < ErrorBase
identifier "InternalServerError"
code 500
end
end
end