-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All dbt errors now have proper error codes/messages The raised message at runtime ends up in result.error.data.message The raised message type at runtime ends up in result.error.data.typename result.error.message is a plaintext name for result.error.code dbt.exceptions.Exception.data() becomes result.error.data
- Loading branch information
Jacob Beck
committed
Mar 7, 2019
1 parent
2ad1166
commit b397868
Showing
7 changed files
with
215 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from jsonrpc.exceptions import JSONRPCError, JSONRPCServerError | ||
|
||
import dbt.exceptions | ||
|
||
|
||
class RPCError(JSONRPCError): | ||
def __init__(self, exc): | ||
super(RPCError, self).__init__(exc.CODE, exc.MESSAGE, data=exc.data()) | ||
|
||
|
||
def server_error(exc): | ||
return JSONRPCServerError(data={'message': str(exc)}) | ||
|
||
|
||
def timeout_error(timeout_value): | ||
return JSONRPCError( | ||
code=10008, | ||
message='RPC timeout error', | ||
data={ | ||
'timeout': timeout_value, | ||
'message': 'RPC timed out after {}s'.format(timeout_value), | ||
} | ||
) | ||
|
||
|
||
def handle_error(exc): | ||
if exc is None: | ||
return None | ||
if isinstance(exc, dbt.exceptions.Exception): | ||
return RPCError(exc) | ||
else: | ||
return server_error(exc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.