mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
A bit of error logging for #1220.
This commit is contained in:
parent
3862bd2376
commit
abcc75a6f2
1 changed files with 9 additions and 6 deletions
|
@ -64,7 +64,7 @@ class CocoModel extends Backbone.Model
|
|||
|
||||
@backedUp = {}
|
||||
schema: -> return @constructor.schema
|
||||
|
||||
|
||||
getValidationErrors: ->
|
||||
errors = tv4.validateMultiple(@attributes, @constructor.schema or {}).errors
|
||||
return errors if errors?.length
|
||||
|
@ -76,7 +76,7 @@ class CocoModel extends Backbone.Model
|
|||
for error in errors
|
||||
console.debug "\t", error.dataPath, ":", error.message
|
||||
return errors
|
||||
|
||||
|
||||
save: (attrs, options) ->
|
||||
options ?= {}
|
||||
options.headers ?= {}
|
||||
|
@ -97,19 +97,19 @@ class CocoModel extends Backbone.Model
|
|||
noty text: "#{errorMessage}: #{res.status} #{res.statusText}", layout: 'topCenter', type: 'error', killer: false, timeout: 10000
|
||||
@trigger "save", @
|
||||
return super attrs, options
|
||||
|
||||
|
||||
patch: (options) ->
|
||||
return false unless @_revertAttributes
|
||||
options ?= {}
|
||||
options.patch = true
|
||||
|
||||
|
||||
attrs = {_id: @id}
|
||||
keys = []
|
||||
for key in _.keys @attributes
|
||||
unless _.isEqual @attributes[key], @_revertAttributes[key]
|
||||
attrs[key] = @attributes[key]
|
||||
keys.push key
|
||||
|
||||
|
||||
return unless keys.length
|
||||
console.debug 'Patching', @get('name') or @, keys
|
||||
@save(attrs, options)
|
||||
|
@ -207,7 +207,10 @@ class CocoModel extends Backbone.Model
|
|||
|
||||
applyDelta: (delta) ->
|
||||
newAttributes = $.extend(true, {}, @attributes)
|
||||
jsondiffpatch.patch newAttributes, delta
|
||||
try
|
||||
jsondiffpatch.patch newAttributes, delta
|
||||
catch error
|
||||
console.error "Error applying delta", delta, "to attributes", newAttributes, error
|
||||
@set newAttributes
|
||||
|
||||
getExpandedDelta: ->
|
||||
|
|
Loading…
Reference in a new issue