Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
OpnSense
Commits
65471b33
Commit
65471b33
authored
Aug 14, 2016
by
Ad Schellevis
Committed by
GitHub
Aug 14, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1140 from pv2b/improve-api-exception-messages
Improve error messages for API calls
parents
9ed6406b
6839fe81
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
5 deletions
+21
-5
ApiControllerBase.php
...e/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php
+20
-4
api.php
src/opnsense/www/api.php
+1
-1
No files found.
src/opnsense/mvc/app/controllers/OPNsense/Base/ApiControllerBase.php
View file @
65471b33
...
...
@@ -59,13 +59,29 @@ class ApiControllerBase extends ControllerRoot
/**
* Raise errors, warnings, notices, etc.
* @param $errno
* @param $errstr
* @param $errno The first parameter, errno, contains the level of the
* error raised, as an integer.
* @param $errstr The second parameter, errstr, contains the error
* message, as a string.
* @param $errfile The third parameter is optional, errfile, which
* contains the filename that the error was raised in, as
* a string.
* @param $errline The fourth parameter is optional, errline, which
* contains the line number the error was raised at, as an
* integer.
* @param $errcontext The fifth parameter is optional, errcontext, which
* is an array that points to the active symbol table
* at the point the error occurred. In other words,
* errcontext will contain an array of every variable
* that existed in the scope the error was triggered
* in. User error handler must not modify error
* context.
* @throws \Exception
*/
public
function
APIErrorHandler
(
$errno
,
$errstr
)
public
function
APIErrorHandler
(
$errno
,
$errstr
,
$errfile
,
$errline
,
$errcontext
)
{
throw
new
\Exception
(
$errstr
.
' ['
.
$errno
.
']'
);
$msg
=
"Error at
$errfile
:
$errline
-
$errstr
(errno=
$errno
)"
;
throw
new
\Exception
(
$msg
);
}
/**
...
...
src/opnsense/www/api.php
View file @
65471b33
...
...
@@ -29,6 +29,6 @@ try {
$response
=
array
();
$response
[
'errorMessage'
]
=
$e
->
getMessage
();
header
(
"Content-Type: application/json;charset=utf-8"
);
echo
htmlspecialchars
(
json_encode
(
$response
),
ENT_NOQUOT
ES
);
echo
json_encode
(
$response
,
JSON_UNESCAPED_SLASH
ES
);
error_log
(
$e
);
}
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