concept custom error in category go

appears as: custom errors, custom error, custom errors
Go in Practice

This is an excerpt from Manning's book Go in Practice.

You don’t have much room for customization when using the Error function within the http package. The response type is hardcoded as plain text, and the X-Content-Type-Options header is set to nosniff. This header tells some tools, such as Microsoft Internet Explorer and Google Chrome, to not attempt to detect a content type other than what was set. This leaves little opportunity to provide a custom error, aside from the content of the plain text string.

Technique 52 Reading custom errors

If an application responds with custom errors, such as those generated by technique 51, this presents an API response with a different structure from the expected response in addition to there being an error.