mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +02:00
Return UnknownError from errorTypeFromCode() for invalid error codes.
The prior behavior was to throw an exception but this was not very helpful when something unexpected happened. Better to at least emit the error message even if the error code is not very helpful.
This commit is contained in:
parent
2b02d37602
commit
aab9e38b9a
@ -41,6 +41,10 @@
|
||||
<p>Allow empty arrays in JSON parser.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Return <code>UnknownError</code> from <code>errorTypeFromCode()</code> for invalid error codes.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Null-terminate list returned by <code>strLstPtr()</code>.</p>
|
||||
</release-item>
|
||||
|
@ -109,7 +109,7 @@ errorTypeFromCode(int code)
|
||||
|
||||
// Error if type was not found
|
||||
if (result == NULL)
|
||||
THROW_FMT(AssertError, "could not find error type for code '%d'", code);
|
||||
result = &UnknownError;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -247,8 +247,8 @@ testRun(void)
|
||||
}
|
||||
CATCH_ANY()
|
||||
{
|
||||
assert(errorCode() == AssertError.code);
|
||||
assert(strcmp(errorMessage(), "could not find error type for code '777'") == 0);
|
||||
assert(errorCode() == UnknownError.code);
|
||||
assert(strcmp(errorMessage(), "message") == 0);
|
||||
}
|
||||
TRY_END();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user